Paperclip Amazon S3 setup with Heroku

前端 未结 2 1737
走了就别回头了
走了就别回头了 2020-12-29 00:27

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

I\'m not sure wha

相关标签:
2条回答
  • 2020-12-29 01:06

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

    0 讨论(0)
  • 2020-12-29 01:11

    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.

    0 讨论(0)
提交回复
热议问题