开发者

Paperclip Amazon S3 setup with Heroku

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

I'm not sure what :path => "/:style/:filename" is.

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 att开发者_如何学编程achment 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?


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.


Note that in Rails 3.1 and above, it should be Rails.root and not RAILS_ROOT

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜