未初始化的常量 AWS::S3::NoSuchBucket (uninitialized constant AWS::S3::NoSuchBucket)


問題描述

未初始化的常量 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 HenriqueIanKevin SylvestreBoriscounterbeingJacques)

參考文件

  1. uninitialized constant AWS::S3::NoSuchBucket (CC BY-SA 3.0/4.0)

#paperclip #ruby-on-rails-3 #amazon-s3






相關問題

帶有 S3 的回形針 - 未定義的方法 (Paperclip with S3 - undefined method)

添加文件上傳進度條的最簡單方法(回形針)Apache/Paperclip/Rails (Easiest way to add file upload progress bar (paperclip) Apache/Paperclip/Rails)

EngineYard:分離代碼和資產 (EngineYard : Segregating the code & assets)

在 rails/paperclip 中處理一系列圖像 (handling an array of images in rails/paperclip)

rails - không thể tạo bản ghi với tệp đã tải lên (rails - can't build a record with uploaded file)

在保存到 Rails 模型之前打開臨時文件 (Open the temporary file before it is saved in Rails model)

Rails - 回形針 - 多張照片上傳不保存 (Rails - paperclip - Multiple photo upload not saving)

回形針不為一種型號存儲替代尺寸,但為另一種型號存儲 (Paperclip is not storing alternative sizes for one model, but does for another)

無法使用 S3 圖像的 image.to_file 使用 Paperclip gem 複製圖像 (Can't copy images with Paperclip gem using image.to_file for S3 images)

Paperclip.interpolates 隨機不返回值 (Paperclip.interpolates randomly not returning a value)

未初始化的常量 AWS::S3::NoSuchBucket (uninitialized constant AWS::S3::NoSuchBucket)

來自基類的 Rails STI 條件子類化 (Rails STI conditional sub-classing from base class)







留言討論