Paperclip Amazon S3 setup with Heroku

拟墨画扇 提交于 2019-11-30 04:07:34

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!