sebvst
sebvst

Reputation: 753

Rails Paperclip S3 signed URL not working anymore

A couple months ago I set up a rails app. Uploaded picture were saved in a private bucket on S3. I could download them through an expiring URL. Now that is not working anymore, even though I did not change anything. What could be the reason? A timezone issue?

My generated Link looks like this: http:// [bucket] .s3-eu-west-1.amazonaws.com//original/image.jpg?AWSAccessKeyId= [AQCCESS_KEY] \u0026Expires=1408020974\u0026Signature= [signature]

With this linked I tried to download a file at 10.56 am central european time on August 10th. Might there be a time zone issue? How to I read the Expires parameter in that URL.

Any idea what could be the problem here?

Thank you in advance!

Upvotes: 1

Views: 839

Answers (2)

sebvst
sebvst

Reputation: 753

Okay, I found the problem:

As I said, the link looks like this:

http:// [bucket] .s3-eu-west-1.amazonaws.com//original/image.jpg?AWSAccessKeyId= [AQCCESS_KEY] \u0026Expires=1408020974\u0026Signature= [signature]

The problem is the u0026 which has to be replaced by "&"-sign. I will think about how to solve the problem. But at least it is identified :)

Upvotes: 0

andHapp
andHapp

Reputation: 3197

This answers your - 'How to I read the Expires parameter in that URL.?' question:

The Expires time is defined as Epoch time. In order to see what that time is, you can run the following ruby code:

require 'date'    
DateTime.strptime("1408020974",'%s').to_s

which returns this:

"2014-08-14T12:56:14+00:00"

Hope it helps.

Upvotes: 1

Related Questions