我安装了Paperclip插件并成功地在本地使用它。当我将其配置为与Amazon S3配合使用时,我一直收到NoSuchBucket(指定的存储桶不存在)错误。Paperclip文档说明如果存储桶不存在,它将被创建,但在我的情况下显然出了问题。
我首先安装了aws-s3 gem(v0.6.2),然后还安装了right_aws gem(v1.9.0)。
两者都有相应的…
我首先安装了aws-s3 gem(v0.6.2),然后还安装了right_aws gem(v1.9.0)。
两者都有相应的…
config.gem "aws-s3", :lib => "aws/s3"
config.gem 'right_aws', :version => '1.9.0'
environment.rb文件中的行
使用paperclip的image.rb文件代码如下:
class Image < ActiveRecord::Base
belongs_to :work
has_attached_file :photo, :styles => {:big => "612x1224>", :small => "180X360>", :thumb => "36x36#"},
:storage => 's3',
:s3_credentials => YAML.load_file("#{RAILS_ROOT}/config/s3.yml")[RAILS_ENV],
:path => ":attachment/:id/:style/:basename.:extension",
:bucket => 'my-unique-image-bucket'
attr_protected :photo_file_name, :photo_content_type, :photo_size
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 3.megabytes
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png', 'image/gif']
end