Issues with Rails, Amazon S3, and protected URLs

Posted by Shpigford on Stack Overflow See other posts from Stack Overflow or by Shpigford
Published on 2010-04-22T21:59:47Z Indexed on 2010/04/22 22:03 UTC
Read the original article Hit count: 426

So I followed this little tutorial about protecting downloads of files that are uploaded to Amazon S3 with Paperclip.

When I've developed locally, it's worked fine, but since pushing the exact same code to a production server...I now get this error from Amazon when I try to access the files:

<Error>
  <Code>InvalidArgument</Code>
  <Message>Either the Signature query string parameter or the Authorization header should be specified, not both</Message>
  <ArgumentValue>Basic dGVjaHVrdWxlbGU6ZWxlbHVrdWhjZXQ=</ArgumentValue>
  <ArgumentName>Authorization</ArgumentName>
  <RequestId>F6E455857C54F95A</RequestId>
  <HostId>X4QA2pw9wpHtJtJ2T8qxCyINjq4PLHQVF4VrlYjpX7Ayh694BgQprh5p8H7NRCAt</HostId>
</Error>

Example URL:

http://s3.amazonaws.com/media.example.com/assets/videos/1/original.mov?AWSAccessKeyId=MY_ACCESS_KEY&Expires=1271972624&Signature=7wWH2WYHPO0o9szwPJbimUMqAig%3D

That URL is generated using AWS::S3::S3Object.url_for using the aws-s3 gem.

So...not even sure where to start. The fact that it works fine when the app is running locally but not when in production really doesn't make sense.

The production server is running Ubuntu 8.04.4 LTS (Hardy).

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about amazon-s3