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 6199651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:13:39+00:00 2026-05-24T04:13:39+00:00

I storing images using paperclip + S3 has_attached_file :image, :whiny => false, :styles =>

  • 0

I storing images using paperclip + S3

has_attached_file :image,
                     :whiny => false,
                     :styles => { :large => "550x340>",
                                  :medium  => "165x165>",
                                  :small => "100x100>",
                                  :thumbnail => "55x55>"},
                     :processors => [:cropper],
                     :storage => :s3,
                     :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
                     :path => "/:id/:style",
                     :bucket => "XXX" 

when I create an object with image every thing goes fine (4 copies of the image with 4 different sizes stored in my S3 Bucket )

The problem comes when I crop the image using JCrop, S3 store 4 copies but with the same size for the cropped image actually the large size.

My controller.rb:

def update
@deal = Deal.find(params[:id])

respond_to do |format|
  if @deal.update_attributes(params[:deal])
    format.html { redirect_to(@deal, :notice => 'Deal was successfully updated.') }
    format.xml  { head :ok }
  else
    format.html { render :action => "edit" }
    format.xml  { render :xml => @deal.errors, :status => :unprocessable_entity }
  end
end
  • 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-24T04:13:40+00:00Added an answer on May 24, 2026 at 4:13 am

    This is how it works:

    • You save the file to amazon s3
    • You request for the file though CDN
    • CDN checks its cache if file is available
    • If not available, request the file from s3, cache it and serve
    • If available serve from cache. This step ensures that your users get a optimal experience. If CDN gets the file from s3 every time, then it will take longer than user getting file directly from s3, which will defeat the purpose of CDN.
    • You crop the image and save modified file to s3
    • You request CDN for file expecting it will give you cropped file
    • CDN checks its cache for the file, finds it and serves the file from cache. It doesn’t ask s3 again if the file was modified

    Now, most optimal way I can think of is to upload the cropped image with a new file name. So that when CDN checks its cache, it doesn’t find it there and asks s3 for the file. You can delete the old file in background using delayed_job or resque.

    Hope, it clarifies things.

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

Sidebar

Related Questions

The best way to store images into MySQL is by storing the image location
I am storing many images in Amazon S3, using a ruby lib ( http://amazon.rubyforge.org/
What's the best practice for storing a large amount of image data in SQL
I'm storing images in a Core Data database. More specifically, I'm using the external
I'm using Paperclip (2.3) to handle image uploads on a Rails 3.0.3 app running
I have an SQLite Database in which I am storing images as BLOB using
I am downloading images using a imageAdapter extending a base class. Im storing them
I am using paperclip for storing files related to the model. The files can
I am currently using paperclip to upload images of items to my site. I
Using Paperclip, I want to grab an image from a URL like this: require

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.