简体   繁体   English

Rails Paperclip S3签名的URL不再起作用

[英]Rails Paperclip S3 signed URL not working anymore

A couple months ago I set up a rails app. 几个月前,我建立了一个Rails应用程序。 Uploaded picture were saved in a private bucket on S3. 上传的图片已保存在S3的专用存储桶中。 I could download them through an expiring URL. 我可以通过过期的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] \&Expires=1408020974\&Signature= [signature] 我生成的链接如下: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. 有了这个链接,我试图在欧洲中部时间8月10日上午10.56下载文件。 Might there be a time zone issue? 可能存在时区问题吗? How to I read the Expires parameter in that URL. 如何读取该URL中的Expires参数。

Any idea what could be the problem here? 知道这里可能是什么问题吗?

Thank you in advance! 先感谢您!

This answers your - 'How to I read the Expires parameter in that URL.?' 这回答了您-“如何读取该URL中的Expires参数。?” question: 题:

The Expires time is defined as Epoch time . 过期时间定义为纪元时间 In order to see what that time is, you can run the following ruby code: 为了了解时间,您可以运行以下ruby代码:

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

which returns this: 返回以下内容:

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

Hope it helps. 希望能帮助到你。

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] \&Expires=1408020974\&Signature= [signature] http:// [bucket] .s3-eu-west-1.amazonaws.com // original / image.jpg?AWSAccessKeyId = [AQCCESS_KEY] \\ u0026Expires = 1408020974 \\ u0026Signature = [签名]

The problem is the u0026 which has to be replaced by " & "-sign. 问题是由“&” -符号来代替它具有u0026。 I will think about how to solve the problem. 我会考虑如何解决问题。 But at least it is identified :) 但至少它是确定的:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM