1

I get the error:

The request signature we calculated does not match the signature you provided. Check your key and signing method.

when saving an attachment in a rake task. the same file file saves correctly via the active admin interface to the same model. The Rake task worked prior to an upgrade to rails 4 and paperclip 4 from 3.

i'm running rails 4.0.2 and ruby 2.1.1 gem "paperclip", "~> 4.1.0"

My paperclip config looks like this:

 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'],
  #      :s3_protocol => "http",  do i need this?
  :s3_endpoint        => 's3-ap-southeast-2.amazonaws.com'

},
:s3_endpoint    =>  's3-ap-southeast-2.amazonaws.com',
:s3_host_name   => 's3-ap-southeast-2.amazonaws.com'

}

why does the rake task not save the attachment?

Will
  • 4,498
  • 2
  • 38
  • 65
  • 1
    Does your rake task have access to the same ENV hash as your main application? [This question/answer](http://stackoverflow.com/questions/15690135/use-environment-variables-in-rake-task) would suggest that it doesn't by default. – Sebastian Iorga Mar 11 '14 at 23:34
  • it certainly used to and it has access to the application models etc, but ill check that out, thanks! – Will Mar 11 '14 at 23:47
  • breaking into pry and inspecting ENV - yes - it has access to ENV at least in development – Will Mar 12 '14 at 04:22
  • also, specifiying http (commented out in the code above) does not fix it. i had hoped that because its in rake, it doesn't have the browsers https status to go on so was defaulting to https, but alas. – Will Mar 12 '14 at 04:24
  • 1
    and i was big fat wrong :) ENV was the culprit! thanks very much. in production the task could get at the config settings for paperclip but they were incomplete. – Will Mar 12 '14 at 09:46
  • ENV is evil so I always suspect ENV for screwing me over. Heck it just did this morning :D Glad it worked out without requiring any major code work. – Sebastian Iorga Mar 12 '14 at 10:56
  • @Will You should write this up as an answer. I ALMOST overlooked the comment and it gave me the hint I needed to solve my issue. Let me know if you do so I can give it an upvote. Many thanks! – neanderslob Nov 13 '15 at 09:02

0 Answers0