【发布时间】:2019-10-22 01:39:18
【问题描述】:
我正在尝试按照文档 (https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html) 中的说明使用预签名 URL 进行上传,我可以检索预签名 URL,但是当我尝试在 Postman 中执行 PUT 时,我收到以下错误:
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
显然,我的看跌期权的结构方式与 AWS 计算签名的方式不匹配。我找不到很多关于这个看跌期权需要什么的信息。
我尝试将 Content-Type 的标头修改为 multipart/form-data 和 application/octet-stream。我还尝试取消选中邮递员中的标题部分,并在我选择文件的地方为表单数据和二进制设置依赖正文类型。 form-data 设置会在调用中添加以下内容:
内容配置:表单数据; name="thefiletosend.txt";文件名="thefiletosend.txt
此外,我注意到邮递员包含了它所谓的“临时标头”,如下所示:
主机:s3.amazonaws.com 内容类型:文本/纯文本 用户代理:PostmanRuntime/7.13.0 接受:/ 缓存控制:无缓存 邮递员令牌:e11d1ef0-8156-4ca7-9317-9f4d22daf6c5,2135bc0e-1285-4438-bb8e-b21d31dc36db 主持人:s3.amazonaws.com 接受编码:gzip,放气 内容长度:14 连接:保持活动 缓存控制:无缓存
Content-Type 标头可能是问题之一,但我不确定如何在邮递员中排除这些“临时标头”。
我在 lambda 中生成预签名 URL,如下所示:
public string FunctionHandler(Input input, ILambdaContext context)
{
_logger = context.Logger;
_key = input.key;
_bucketname = input.bucketname;
string signedURL = _s3Client.GetPreSignedURL(new GetPreSignedUrlRequest()
{
Verb = HttpVerb.PUT ,
Protocol = Protocol.HTTPS,
BucketName = _bucketname,
Key = _key,
Expires = DateTime.Now.AddMinutes(5)
});
returnObj returnVal = new returnObj() { url = signedURL };
return JsonConvert.SerializeObject(returnVal);
}
【问题讨论】:
标签: amazon-web-services amazon-s3 postman pre-signed-url