views:

120

answers:

1

When the an image is stored to Amazon S3 using Paperclip the url of the image is too long:

e.g. http://s3.amazonaws.com/railsapp/Users/am/Desktop/railsapp/public/system/avatars/1/thumb/16110022.jpg?1171724004 (this is basically http://s3.amazonaws.com/[bucketname]/[path on mac to image])

This is in my user model:

  has_attached_file :avatar, 
                :styles => { :thumb => "100x100>", :medium =>"250x250>" },
                :default_style => :thumb,
                :default_url => "/images/:attachment/missing_:style.png",
                :storage => :s3,                    
                :s3_credentials => "#{RAILS_ROOT}/config/amazon_s3.yml"

How can I make the url shorter and so that it doesn't include the long link to the file? At the same time, is there a way to prevent the original file (not the resized ones) form being saved?

A: 

Have you tried defining the :path option such as :path => "avatars/:id/:style/:filename"?

theIV
Hi there, what is the difference between :path and :url?
aaronmase
Just tried - :path => "/avatars/:id/:style/:basename.:extension" - and it worked well - thanks. I am still confused about the purpose of url though
aaronmase
I don't know what `url` has as an effect on saving the file, I thought it was just something used during retrieving. I've also never set `url`, just `path`.
theIV