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 dates in my local Oracle 11g database that are in this format:
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 SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have a matrix report now that has Position, Hours and Wages for a location
Have searched the database but need to specifically sum(of hours flown or days off)in
Have a bunch of WCF REST services hosted on Azure that access a SQL
Have some code: using (var ctx = new testDataContext()) { var options = new
Have a look at one of my websites: moskah.com The problem is that it
Have a simple contact us XPage created. Have server side validation in place that

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.