Ruby on Rails / Paperclip / AWS :: S3 :: NoSuchBucket error

I installed the paperclip plugin and was able to use it locally. When I configured it to work with amazon S3, I get a NoSuchBucket error all the time (the specified bucket does not exist). The Paperclip documentation says that a bucket will be created if it does not exist, but something is wrong in my case.

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

both have corresponding

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

in environment.rb file

The code for the image.rb file using 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 
+3
source share
5 answers

I'm not quite sure if this is the case, but your s3_credentials download is different from what I use on my production sites.

My configuration line:

 :s3_credentials => "#{RAILS_ROOT}/config/s3.yml" 

Instead

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

he should create, but a bucket, but it was a mistake at one point:

http://groups.google.com/group/paperclip-plugin/browse_thread/thread/42f148cee71a0477

Recently, I had this problem, and it turned out that the server time was very inactive, and s3 did not allow any updates "in the future" or the like, but the rails error was NoSuchBucket ... confusing

..

+1
source

I installed the s3fox plugin for firefox and created a bucket with the plugin. Paperclip now works great with S3 as the identified bucket is already created.

But I'm still curious about the impossibility of creating a paper clip to create new buckets with the code above.

0
source

In case someone starts here via google: I saw this same error when I mistakenly switched the order of the 2nd and 3rd parameters, which I switched to AWS::S3::S3Object.store .

0
source

This is not your case, but AWS does not allow uppercase letters in the bucket name, and the clip does not verify this without running create_bucket .

0
source

Source: https://habr.com/ru/post/1344722/


All Articles