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
source share