Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:10:22+00:00 2026-05-31T19:10:22+00:00

I have a GalleryPhoto model with a paperclip attachment that gets processed into a

  • 0

I have a GalleryPhoto model with a paperclip attachment that gets processed into a number of styles. Some styles need to be publicly readable; some need to be private.

Here’s my model:

class GalleryPhoto < ActiveRecord::Base
  has_attached_file :image,
    :storage => :s3,
    :bucket => ":bucket.myapp_#{Rails.env == 'production' ? 'production' : 'development'}",
    :path => "images/galleries/:gallery_id/:id/:style_:id.:extension",
    :url => "/images/galleries/:gallery_id/:id/:style_:id.:extension",
    :s3_credentials => { :access_key_id => 'XXXXXXXXX', :secret_access_key => 'XXXXXXXXX' },
    :s3_permissions => {
      :thumbnail => :public_read,
      :small => :public_read,
      :medium => :public_read,
      :large => :public_read,
      :small_download => :private,
      :original => :private
    },
    :styles => {
      :thumbnail => {
        :geometry => "80x80>"
      },
      :small => {
        :geometry => "200x200>"
      },
      :medium => {
        :geometry => "400x400>"
      },
      :large => {
        :geometry => "600x600>"
      },
      :small_download => {
        :geometry => "600x600"
      }
    }
end

Here’s my paperclip initializer:

Paperclip.interpolates :bucket do |attachment, style|
  [:original, :small_download].include?(style) ? "private" : "public"
end

Paperclip.interpolates :gallery_id do |attachment, style|
  attachment.instance.gallery_id
end

I have four buckets as such:

private.myapp_development
private.myapp_production
public.myapp_development
public.myapp_production

The private.xxx buckets shouldn’t be publicly accessible, but the public.xxx buckets should be publicly readable.

I can get the app to serve the styles that have been marked public in the public buckets, but I cannot do uploads or have my download action, which serves the private styles, work.

Here’s the log when I try to do an upload:

[paperclip] Saving attachments.
[paperclip] saving images/galleries/242/22034/original_22034.jpg
   (0.8ms)  ROLLBACK
Completed 500 Internal Server Error in 8013ms

Errno::EPIPE (Broken pipe):
  app/controllers/gallery_photos_controller.rb:13:in `create'

Here’s the log when I try to use my download action for the private styles:

Sent file images/galleries/222/19515/original_19515.jpg (0.2ms)
Completed 500 Internal Server Error in 861ms

ActionController::MissingFile (Cannot read file images/galleries/222/19515/original_19515.jpg):
  app/controllers/gallery_photos_controller.rb:22:in `download'

What am I missing?

rails 3.1.1
paperclip 2.7.0
aws-sdk 1.3.7
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:10:23+00:00Added an answer on May 31, 2026 at 7:10 pm

    Paperclip just did not want to store in two buckets with the same attachment. So I separated out the styles into public/private “folders” in the same bucket, with different permissions for each style.

    Here’s my model code:

      has_attached_file :image,
        :storage => :s3,
        :bucket => "myapp-#{Rails.env == 'production' ? 'production' : 'development'}",
        :path => ":bucket/images/galleries/:gallery_id/:id/:style_:id.:extension",
        :url => "/:bucket/images/galleries/:gallery_id/:id/:style_:id.:extension",
        :s3_credentials => { :access_key_id => 'XXXXX', :secret_access_key => 'XXXXXXXXX' },
        :s3_permissions => {
          :thumbnail => :public_read,
          :small => :public_read,
          :medium => :public_read,
          :large => :public_read,
          :small_download => :private,
          :original => :private
        },
        :styles => {
          :thumbnail => {
            :geometry => "80x80>"
          },
          :small => {
            :geometry => "200x200>"
          },
          :medium => {
            :geometry => "400x400>"
          },
          :large => {
            :geometry => "600x600>"
          },
          :small_download => {
            :geometry => "600x600"
          }
        }
    

    When I check the permissions on the files in the s3 console, they are appropriate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have some div elements on a page that I need to hide by default
This is a similar question to this . I have a GalleryPhoto model with
I have a Django query and some Python code that I'm trying to optimize
Have a SQL problem, adding this model all works correctly, the problem is in
Have I in some way delete this Task or it is self-destroyed? Task.Factory.StartNew(() =>
Have such user_session model: class UserSession < Authlogic::Session::Base logout_on_timeout true # default if false
Have a simple form that has a PictureBox in one location. I want to
Have a photography site that I want to prevent image copying from. How can
Have run into a bug with glibc's malloc(): http://sourceware.org/bugzilla/show_bug.cgi?id=4349 and am thinking a work
Have a problem that seems easy on paper but i'm having a big problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.