【发布时间】:2019-04-05 12:03:56
【问题描述】:
尝试使用 s3 预签名 url 下载文件。我们与谷歌分析集成,因为所有超链接都附加了一个额外的查询参数“_ga”。
预签名的 url 构造类似于 https://someapprouter.herokuapp.com/ant/storage/1619958100/f8c40a75/file?response-content-disposition=attachment%3B%20fileName%3D%22PersonSampleFormat.csv%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190403T191315Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=ACKJOEK2Q%2F20190403%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=xxxx
但是当我们尝试从浏览器下载文件时,会添加额外的查询参数,这会导致下载错误。 Finla URL 就像https://someapprouter.herokuapp.com/ant/storage/1619958100/f8c40a75/file?response-content-disposition=attachment%3B%20fileName%3D%22PersonSampleFormat.csv%22&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190403T191315Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=AKJOEK2Q%2F20190403%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=xxxx&_ga=yyyyy
例外:
错误>
SignatureDoesNotMatch我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
当 s3 进行签名匹配时,我们如何排除查询参数 _ga。
【问题讨论】:
-
我不认为你可以。考虑不要将
_ga添加到这些链接中。 -
看来我们无法排除。现在我在重定向到目标之前从预签名的 url 中删除 _ga 参数。
标签: amazon-web-services amazon-s3 google-analytics