我正在尝试使用邮差上传一个文件。我已经通过点击“body”(在postman中)->二进制->选择文件附加了文件。我使用S3上载预签名的URL。在url中,文件的名称与我在Postman中选择的文件的名称完全相同。运行请求时,我得到一个错误:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<AWSAccessKeyId>...</AWSAccessKeyId>
<StringToSign>PUT
text/plain
1551977056
x-amz-acl:private
/wiivv-staging-private-storage/measurement/6506684788010901504/1551405460831/topLeft-2.jpeg</StringToSign>
<SignatureProvided>...</SignatureProvided>
<StringToSignBytes>...</StringToSignBytes>
<RequestId>DB2FC5FE064CF49A</RequestId>
<HostId>zbsLj7mcuXJa8D9JX1jFN1Lo+lI02/EvJreAXmPQjPezmU1sucQamXuqlGoUBzAq3nAaejx3doA=</HostId>
</Error>
但是,通过导出postman请求(通过单击“Code”)来获得curl命令,我得到了:
curl -X PUT \
'[s3-presigned-url]' \
-H 'Postman-Token: 84700b0d-0cd2-4de5-b52c-7de39a12253e' \
-H 'cache-control: no-cache'
并添加一个用于上载文件的附加选项:
curl -X PUT \
'[s3-presigned-url]' \
-H 'Postman-Token: 84700b0d-0cd2-4de5-b52c-7de39a12253e' \
-H 'cache-control: no-cache'
--upload-file ~/topLeft-2.jpeg
PUT /measurement/6506684788010901504/1551405460831/topLeft-2.jpeg?AWSAccessKeyId=AKIAIKNR3HJGZI24MDTQ&Expires=1554393626&Signature=OaqaUqB2%2B3jp2AH97aWKujV3ZD8%3D&x-amz-acl=private
Content-Type: multipart/form-data; boundary=--------------------------092560820091438222667657
cache-control: no-cache
Postman-Token: e45247b4-0fc4-4adb-8e7b-effb82dc8e73
User-Agent: PostmanRuntime/7.6.1
Accept: */*
Host: wiivv-staging-private-storage.s3.amazonaws.com
accept-encoding: gzip, deflate
content-length: 199703
name=topLeft-2.jpegfilename=[object Object]
HTTP/1.1 403
status: 403
x-amz-request-id: 640967A618ABD4A0
x-amz-id-2: IVZtpEDxEEo0R7JaQWrsOi8/6UESbKH4dZNWDnwJDJBhv1ppZx56cvMPt6xT4ZJ3qWiFernsu54=
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Thu, 04 Apr 2019 15:58:34 GMT
Connection: close
Server: AmazonS3
<?xml version="1.0" encoding="UTF-8"?> <Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>AKIAIKNR3HJGZI24MDTQ</AWSAccessKeyId><StringToSign>PUT multipart/form-data; boundary=--------------------------092560820091438222667657 1554393626 x-amz-acl:private /wiivv-staging-private-storage/measurement/6506684788010901504/1551405460831/topLeft-2.jpeg</StringToSign><SignatureProvided>OaqaUqB2+3jp2AH97aWKujV3ZD8=</SignatureProvided><StringToSignBytes>50 55 54 0a 0a 6d 75 6c 74 69 70 61 72 74 2f 66 6f 72 6d 2d 64 61 74 61 3b 20 62 6f 75 6e 64 61 72 79 3d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 30 39 32 35 36 30 38 32 30 30 39 31 34 33 38 32 32 32 36 36 37 36 35 37 0a 31 35 35 34 33 39 33 36 32 36 0a 78 2d 61 6d 7a 2d 61 63 6c 3a 70 72 69 76 61 74 65 0a 2f 77 69 69 76 76 2d 73 74 61 67 69 6e 67 2d 70 72 69 76 61 74 65 2d 73 74 6f 72 61 67 65 2f 6d 65 61 73 75 72 65 6d 65 6e 74 2f 36 35 30 36 36 38 34 37 38 38 30 31 30 39 30 31 35 30 34 2f 31 35 35 31 34 30 35 34 36 30 38 33 31 2f 74 6f 70 4c 65 66 74 2d 32 2e 6a 70 65 67</StringToSignBytes><RequestId>640967A618ABD4A0</RequestId><HostId>IVZtpEDxEEo0R7JaQWrsOi8/6UESbKH4dZNWDnwJDJBhv1ppZx56cvMPt6xT4ZJ3qWiFernsu54=</HostId></Error>
好吧,不管是谁来讨论这个问题,这里是我如何解决的。在我们的应用程序逻辑中,我们现在用给定的内容类型application/octet-stream(我认为这并不重要,重要的是覆盖邮递员桌面应用程序自动添加的“text/plain”)预先签署了url并将指定的内容类型与邮递员请求一起发送。
let s3Param = {
Bucket: this.bucketName,
Key: filePath,
Expires: bucketConfig.uploadExpireInSecond,
ACL: bucketConfig.acl,
ContentType: 'application/octet-stream',
};
s3.getSignedUrl('putObject', s3Param, ...);
在邮递员请求头中,我们有“conent-type:application/octet-stream”
我正试图上传一个媒体文件(图片,任何扩展名jpg/png/jpeg或视频)到aws s3桶,从邮递员我创建了我的预签名url在我的后端如下 这成功地生成了一个url,但我似乎无法使用postman来测试它,这是我如何在postman中调整请求的截图 我所尝试的: 在上面的代码中,我尝试将签名版本v4添加到params中,但它给了我一个错误,说出了意外的关键字。我甚至尝试将其添加到aws配置和s3中
我正在尝试使用预先签名的URL将文件上传到Amazon的S3。我从生成URL的服务器获取URL https://com-example-mysite.s3-us-east-1.amazonaws.com/userFolder/ImageName?X-Amz安全令牌=xxfoox///xxbarxx= 不幸的是,当我将其传递给Refught2时,它会修改试图将其转换为URL的字符串。我设置了,它解决
这里是我的node.js预签名URL的生成 那么我在URL生成或卷曲方面的问题在哪里呢?谢谢
tl;dr-从浏览器向从服务器(AWS S3)获取的预签名url发出的请求获得,但以下请求获得 这是我负责AWS及其S3服务的服务器端代码: 知道我做错了什么吗?
我正在开发一个特性,使用Angular/预签名url和API Gateway/lambda生成预签名url将文件上传到S3。 我的工作流描述如下: 从模板中获取选定文件 请求我的api(网关/lambda)使用文件名生成预签名的URL。 const body={filename:this.selectedfile.name}const preSignedUrl=await this.http.po
问题内容: 我正在尝试使用预签名的URL将文件上传到Amazon的S3。我从生成URL的服务器获取URL,并将其作为JSON对象的一部分发送给我。我将URL作为字符串获取,如下所示: https://com-example-mysite.s3-us- east-1.amazonaws.com/userFolder/ImageName?X-Amz-Security- Token=xxfooxx%2F