我正在尝试按照文档 ( 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>
Run Code Online (Sandbox Code Playgroud)
显然,我的 put 调用的结构方式与 AWS 计算签名的方式不匹配。我找不到很多关于这个看跌调用需要什么的信息。
我试图将 Content-Type 的标头修改为 multipart/form-data 和 application/octet-stream。我还尝试在 postman 中取消勾选 headers 部分,并依赖正文类型来选择文件的表单数据和二进制设置。表单数据设置导致以下添加到调用中:
内容配置:表单数据;name="thefiletosend.txt"; 文件名="thefiletosend.txt
此外,我注意到邮递员包括它所谓的“临时标题”,如下所示:
主机:s3.amazonaws.com Content-Type:text/plain User-Agent:PostmanRuntime/7.13.0 Accept:/ Cache-Control:no-cache Postman-Token:e11d1ef0-8156-4ca7-9317-9f4d22daf6c5,2135bc0e-128 -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; …
Run Code Online (Sandbox Code Playgroud)