問題描述
未初始化的常量 AWS::S3::NoSuchBucket (uninitialized constant AWS::S3::NoSuchBucket)
I am using Rails 3 with the following code...
config.gem "aws-s3", :version => ">= 0.6.2", :lib => "aws/s3"
config.gem 'right_aws', :version => '2.0.0'
model.rb
has_attached_file :video,
:storage => :s3,
:s3_credentials => "#{::Rails.root.to_s}/config/s3.yml",
:path => ":attachment/:id/:style/:basename.:extension"
# Paperclip Validations
validates_attachment_presence :video
validates_attachment_content_type :video, :content_type => ['application/x-shockwave-flash', 'application/x-shockwave-flash', 'application/flv', 'video/x-flv']
s3.yml
development:
bucket_name: tekbookvideo
access_key_id: xxxx
secret_access_key: yyyy
production:
bucket_name: tekbookvideo
access_key_id: xxxx
secret_access_key: yyyy
And am getting the uninitialized constant AWS::S3::NoSuchBucket error...
I do not know what to do anymore...
參考解法
方法 1:
I encountered this problem and experienced a very large headache over it. My eventual solution was to log in to amazon and create a new bucket. Then I set the name of the bucket in the model as a parameter like so...
has_attached_file :video,
:storage => :s3,
:bucket => 'bucketname',
...
方法 2:
It appears to be a bug in the current version of Paperclip. See:
https://github.com/thoughtbot/paperclip/issues/issue/363
方法 3:
I heard people had this issue because there were using european bucket which is not support by aws3
方法 4:
Posted this on a similar thread, but here it is again:
I was just having this very same issue. Then I read something about Paperclip creating buckets where they don't exist. I appended a 1 to the end of my already created bucket name, and all of a sudden it worked. I think it might have something to do with the other end. Try setting the bucket name to something other than the one you've probably already created... Highly counter intuitive...
方法 5:
I created a european bucket first that didn't work. Recreating the bucket again in the standard US location did the trick for me. (Thx Boris).
(by Joao Henrique、Ian、Kevin Sylvestre、Boris、counterbeing、Jacques)