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

amazon-s3, paperclip, ruby-on-rails

Solution

I'm not entirely sure this is it, but your loading of the s3_credentials is different than what I'm using on my production sites.

My config line is:

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

Instead of

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

Problem

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. I first insalled aws-s3 gem (v0.6.2) then also installed right_aws gem (v1.9.0) both have corresponding ``` config.gem "aws-s3", :lib => "aws/s3" config.gem 'right_aws', :version => '1.9.0' ``` lines in environment.rb file 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 ```

Original source