I am getting the following error when trying to upload an image using paperclip and s3 storage. The app worked fine uploading locally, but when I’ve made the required changes to use s3 I get the following:
NameError in ImagesController#create
uninitialized constant AWS::S3::Base
Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
gem 'dynamic_form'
end
gem 'aws-sdk'
gem 'paperclip'
models/Image.rb
class Image < ActiveRecord::Base
has_attached_file :file,
:styles => {
:featured => "970x560>",
:thumb => "192x112>"
},
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/amazon_s3.yml"
end
config/amazon_s3.yml
bucket: myapp-dev
access_key_id: ####################
secret_access_key: ################################
Bundled gems:
aws-sdk (1.2.5)
paperclip (2.4.5)
rails (3.1.3)
Paperclip 2.4.5 still uses the
aws-s3gem. (The README on Github refers toaws-sdk, but that’s only for the unreleased master branch).Change your Gemfile line to:
or use the master branch instead of the stable version (which of course has some risk involved):
UPDATE: Paperclip 2.5.0, released on 1/13/2012, now uses
aws-sdk.