views:

262

answers:

1

has_attached_file :image, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "/:style/:filename"

What is this :path => "/:style/:filename"`

I also want to to include the style for this attached image, is that what the :path is? the style I want is this: :styles => { :medium => "275x275>", :thumb => "175x155>" }

Basically what's going on here is that I'm setting up on heroku and I'm having to use S3 which seems straightforward just not used to this attachment convention stuff.

Also, I just signed up for an S3 account... but heroku was spouting that its free or something. What's the deal with that?

+1  A: 

The 'path' specifies the location on S3 where the files will be stored. Thus, if you specify an attachment as:

 has_attached_file :image, 
    :styles => { :medium => "275x275>", :thumb => "175x155>" },
    :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/amazon_s3.yml",
    :path => "user/:attachment/:style/:id.:extension"

A sample URL will be:

http://s3.amazonaws.com/bucket/user/image/thumb/347853856.jpg

Finally, S3 is NOT free (Heroku simply states transfer / uploads are not counted in the usage based calculations). Heroku's documentation is excellent if you need further information.

Kevin Sylvestre