回形针使用Heroku设置Amazon S3

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

我不确定是什么:path => "/:style/:filename"是。

我还想为这个附加图像添加样式,那是什么:路径是什么? 我想要的样式是:styles => { :medium => "275x275>", :thumb => "175x155>" }

基本上这里发生的是我正在设置heroku并且我不得不使用S3,这似乎很简单,只是不习惯这个附件约定的东西。

此外,我刚刚注册了一个S3帐户……但是heroku正在宣传它的免费或其他东西。 这有什么用?

‘path’指定S3上存储文件的位置。 因此,如果您将附件指定为:

  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" 

示例url将是:

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

最后,S3不是免费的(Heroku只是声明传输/上传不计入基于使用情况的计算)。 如果您需要更多信息,Heroku的文档非常好。

请注意,在Rails 3.1及更高版本中,它应该是Rails.root而不是RAILS_ROOT