Reputation: 819
I'm having issue with paperclip and heroku and really need help.I've lost the past 2 days getting stuck on this and none of the link i could found helped :
https://github.com/igor-alexandrov/paperclip-aws"
"http://www.codeitive.com/0QHVXqkUVV/heroku-paperclip-s3-error-%3E- awss3errorssignaturedoesnotmatch.html"
"https://devcenter.heroku.com/articles/paperclip-s3#international-users-additional-configuration"
"http://dchua.com/2011/12/27/how-to-get-paperclip-and-aws-s3-singapore-and-european-buckets-working/"
"http://www.kahfei.com/?p=389"
"http://www.conandalton.net/2011/02/paperclip-s3-and-european-buckets.html"
"http://stackoverflow.com/questions/20424724/ruby-on-rails-paperclip-amazon-aws-s3-heroku"
"http://stackoverflow.com/questions/7257745/rails-3-amazon-s3-paperclip-eu-problem"
In the beginning i wanted to use an european S3 location but since it seems to make everything more complicated i've decided to switch back to the default US location.
I've setup my VARS as follow on terminal :
$ heroku config:set S3_BUCKET_NAME=your_bucket_name
$ heroku config:set AWS_ACCESS_KEY_ID=your_access_key_id
$ heroku config:set AWS_SECRET_ACCESS_KEY=your_secret_access_key
Then inside my config/environment/production.rb :
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
When going to my website and trying to upload a picture my heroku log is as follow :
Running `bundle exec rake db:seed` attached to terminal... up, run.8070
rake aborted!
AWS::S3::Errors::SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-v1-1.64.0/lib/aws/core/client.rb:375:in `return_or_raise'
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-v1-1.64.0/lib/aws/core/client.rb:476:in `client_request'
(eval):3:in `put_object'
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-v1-1.64.0/lib/aws/s3/s3_object.rb:1765:in `write_with_put_object'
/app/vendor/bundle/ruby/2.0.0/gems/aws-sdk-v1-1.64.0/lib/aws/s3/s3_object.rb:611:in `write'
/app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.2.1/lib/paperclip/storage/s3.rb:360:in `block in flush_writes'
/app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.2.1/lib/paperclip/storage/s3.rb:331:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.2.1/lib/paperclip/storage/s3.rb:331:in `flush_writes'
/app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.2.1/lib/paperclip/attachment.rb:238:in `save'
/app/vendor/bundle/ruby/2.0.0/gems/paperclip-meta-1.2.0/lib/paperclip-meta/attachment.rb:16:in `save_with_meta_data'
/app/vendor/bundle/ruby/2.0.0/gems/paperclip-4.2.1/lib/paperclip/has_attached_file.rb:91:in `block in add_active_record_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:441:in `instance_exec'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:441:in `block in make_lambda'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:225:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:225:in `block in halting_and_conditional'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/callbacks.rb:302:in `create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/persistence.rb:142:in `save!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/validations.rb:43:in `save!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:291:in `block in save!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:347:in `block in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:220:in `transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/transactions.rb:291:in `save!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/persistence.rb:51:in `create!'
/app/db/seeds.rb:9:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/engine.rb:547:in `load_seed'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:250:in `load_seed'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:180:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:seed
Obviously i've double checked my heroku configs and trying to input both key and bucket again => no change.
At this point i've tried so many stuff that i'm at lost. Setting heroku stuff inside my model after attached_files Setting heroku YAML file in addition to heroku config var Tried both european and us standard buckets
If anyone has any idea.. All the research i did on that error didn't help one bit : AWS::S3::Errors::SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
Upvotes: 0
Views: 633
Reputation: 819
Ok just go it working so for the next person having that issue :
-Don't follow the heroku paperclip tutorial
-Create a aws.yml file in your config folder with inside :
development:
access_key_id: "xxxxxinquote"
secret_access_key: "yyyyyinquote"
test:
access_key_id: abc...
secret_access_key: abc...
production:
access_key_id: "xxx"
secret_access_key: "yyyy"
-Inside all your models with file upload put :
has_attached_file :image,
:styles => { :medium => "460x>", :thumb => "100x100>",:vnice=> "400x" },
:storage => :s3,
:bucket => 'hohohohoho',
:s3_credentials => "#{Rails.root}/config/aws.yml",
:path => "resources/:id/:style/:basename.:extension
Then inside your production or/and dev.rb
config.paperclip_defaults = {
:storage => :s3,
:bucket => ENV['S3_BUCKET_NAME'],
:s3_credentials => {
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
Note : :bucket is OUTSIDE the s3 credentials unlike what is said in the tutorial.
Hope it can help someone
Upvotes: 1