Credentials missing when uploading photos with Paperclip and Amazon s3
I am having problems uploading photos to S3 using the Paperclip program. Photos are uploading to the site correctly, but the message "Credentials not available" appears when uploading new posts. I tried to reset my S3 keys, tried to change the access of the encoded variable, but didn't work. I'm pretty sure this is a photo issue, because if I submit the form without a photo, it submits correctly (albeit without a photo).
Here is the model (one of two models, but the script is the same):
class Outfit < ActiveRecord::Base
attr_accessible :gender, :description, :user_id, :photo, :photo_file_name
has_many :outfit_clothes, :dependent => :destroy
has_many :like_relationships, :as => :liked, :dependent => :destroy
belongs_to :user
validates :gender, :presence => true
validates :photo_file_name, :presence => true
has_attached_file :photo,
:storage => :s3,
:bucket => 'cold_fusion',
:s3_credentials => {
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET']
}
end
Here is the bug report
RuntimeError in OutfitsController # create
RuntimeError in OutfitsController#create
Missing credentials
Rails.root: /Users/calebballoch/rails_projects/product_tech
Application Trace | Framework Trace | Full Trace
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/default_signer.rb:47:in `initialize'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:371:in `new'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:371:in `block in <class:Configuration>'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:311:in `call'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:311:in `block in add_option_with_needs'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:307:in `block (2 levels) in add_option_with_needs'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:307:in `collect'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/configuration.rb:307:in `block in add_option_with_needs'
rspec-core/ruby/1.9.1/gems/aws-sdk-1.3.4/lib/aws/core/service_interface.rb:50:in `initialize'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:188:in `new'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:188:in `s3_interface'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:193:in `s3_bucket'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:197:in `s3_object'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:293:in `block in flush_writes'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:279:in `each'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/storage/s3.rb:279:in `flush_writes'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip/attachment.rb:214:in `save'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:468:in `block in save_attached_files'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:461:in `block in each_attachment'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:460:in `each'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:460:in `each_attachment'
rspec-core/ruby/1.9.1/gems/paperclip-2.6.0/lib/paperclip.rb:467:in `save_attached_files'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:410:in `_run_save_callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/callbacks.rb:264:in `create_or_update'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/persistence.rb:37:in `save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/validations.rb:50:in `save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/attribute_methods/dirty.rb:22:in `save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:208:in `transaction'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:241:in `block in save'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/transactions.rb:240:in `save'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/base.rb:167:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/rendering.rb:10:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:425:in `_run__557217090004664767__process_action__2570414948427976814__callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/callbacks.rb:17:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/rescue.rb:17:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in `block in instrument'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/notifications.rb:53:in `instrument'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/base.rb:121:in `process'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:45:in `process'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal.rb:193:in `dispatch'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_controller/metal.rb:236:in `block in action'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:65:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:29:in `call'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:75:in `optimized_each'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
rspec-core/ruby/1.9.1/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:532:in `call'
rspec-core/ruby/1.9.1/gems/hirefireapp-0.0.6/lib/hirefireapp/middleware.rb:27:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/etag.rb:23:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/conditionalget.rb:35:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/head.rb:14:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/flash.rb:247:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/session/abstract/id.rb:195:in `context'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/session/abstract/id.rb:190:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/cookies.rb:331:in `call'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/query_cache.rb:64:in `call'
rspec-core/ruby/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/reloader.rb:68:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/sendfile.rb:101:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
rspec-core/ruby/1.9.1/gems/railties-3.1.3/lib/rails/rack/logger.rb:13:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/methodoverride.rb:24:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/runtime.rb:17:in `call'
rspec-core/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/lock.rb:15:in `call'
rspec-core/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/static.rb:53:in `call'
rspec-core/ruby/1.9.1/gems/railties-3.1.3/lib/rails/engine.rb:456:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/content_length.rb:14:in `call'
rspec-core/ruby/1.9.1/gems/railties-3.1.3/lib/rails/rack/log_tailer.rb:14:in `call'
rspec-core/ruby/1.9.1/gems/rack-1.3.6/lib/rack/handler/webrick.rb:59:in `service'
/Users/calebballoch/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/calebballoch/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/calebballoch/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Request
Parameters:
{"utf8"=>"β",
"authenticity_token"=>"loSqVZPx/d/LO2zwlG5xGaqanDJYrzKCd43zbIx19Lk=",
"outfit"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x0000010650f300 @original_filename="Shirley欒欒11.jpg",
@content_type="image/jpeg",
@headers="Content-Disposition: form-data; name=\"outfit[photo]\"; filename=\"Shirley\xE6\xAC\xA2\xE6\xAC\xA211.jpg\"\r\nContent-Type: image/jpeg\r\n",
@tempfile=#<File:/var/folders/8f/8fdj0RXTE3SPyd7COgaQ1k+++TI/-Tmp-/RackMultipart20120223-46528-16vxkb0>>,
"gender"=>"1",
"description"=>"asdfas"},
"commit"=>"Create an outfit"}
Show session dump
Show env dump
Response
Headers:
Any help would be much appreciated.
source to share
I had a similar problem in a test environment for VersionEye . The problem is that ENV ['S3_KEY'] returned an empty string. And even with fakeS3 it was a problem. Took me 6 hours to figure it out.
source to share