答案 0 :(得分:3)
如果您想在整个项目中使用s3,请按照以下步骤进行操作:
在development.rb
config.paperclip_defaults = {
:storage => :s3,
:path => "/resources/:class/:id_partition/:style/:id-:basename.:extension",
:s3_credentials => {
:bucket => ENV["AWS_BUCKET"],
:access_key_id => ENV["AWS_ACCESS_KEY_ID"],
:secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
}
}
或
如果您想将其与特定型号一起使用,请遵循以下代码:
has_attached_file :avatar,
:styles => { :small => "45x45#" },
:path => "/resources/:class/:attachment/:id/:style/:filename",
:storage => :s3,
:s3_host_name => ENV["S3_HOST_NAME"],
:s3_credentials => {
:bucket => ENV["AWS_BUCKET"],
:access_key_id => ENV["AWS_ACCESS_KEY_ID"],
:secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
}