Ruby on Rails的/回形针/ AWS :: S3 :: NoSuchBucket错误回形针、错误、Rails、on

2023-09-11 09:51:09 作者:胡子茬

我安装回形针插件,并能够在本地使用它。当我将其配置与Amazon S3我不断收到NoSuchBucket工作(指定斗不存在)的错误。回形针文档指出铲斗将创建,如果它不存在,但显然 事情错了我的情况。

I installed the paperclip plugin and was able to use it locally. When I configured it to work with amazon S3 I keep getting the NoSuchBucket (The specified bucket does not exist) error. Paperclip documentation states that the bucket will be created if it doesn't exist but clearly something is going wrong in my case.

我第一次insalled AWS-S3宝石(v0.6.2) 然后还安装right_aws宝石(v1.9.0)

I first insalled aws-s3 gem (v0.6.2) then also installed right_aws gem (v1.9.0)

两人都相应

config.gem "aws-s3", :lib => "aws/s3"
config.gem 'right_aws', :version => '1.9.0'

在environment.rb文件中行

lines in environment.rb file

在code与回形针的image.rb文件如下:

The code for the image.rb file with paperclip is as follows:

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

推荐答案

我不完全相信,这是它,但你的s3_credentials的负荷比我用我的生产基地有什么不同。

解决方案

我的配置行是:

My config line is:

相反

:s3_credentials => YAML.load_file("#{RAILS_ROOT}/config/s3.yml")[RAILS_ENV]