我正在尝试通过一个多格式的aws4请求发送一个图片到aws后端。我正在使用postman。下面是错误输出。
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>InvalidArgument</Code>
<Message>x-amz-content-sha256 must be UNSIGNED-PAYLOAD, STREAMING-AWS4-HMAC-SHA256-PAYLOAD, or a valid sha256 value.</Message>
<ArgumentName>x-amz-content-sha256</ArgumentName>
<ArgumentValue>null</ArgumentValue>
<RequestId>7D78494C962E781C</RequestId>
<HostId>RLuxhuFW89Qfyspp8BCX4IaoQRqAx8yCk7OTeprRwlqH5OurASuqPNU7WbFcZPItXPcHk/8XBgw=</HostId>
</Error>
下面是我得到的SubmitTo
数据
"submitTo": {
"url": "https://optelos-quadro.s3.amazonaws.com",
"method": "POST",
"contentType": "multipart/form-data",
"formData": {
"key": "Redacted",
"content-type": "image/jpeg",
"content-disposition": "inline; filename=file1.JPG",
"x-amz-credential": "Redacted/20181015/us-west-2/s3/aws4_request",
"x-amz-algorithm": "AWS4-HMAC-SHA256",
"x-amz-date": "20181015T000000Z",
"policy": "eyJleHBpcmF0aW9uIjoiMjAxOC0xMC0xNlQxNDozOTowMC4wMTBaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0Ijoib3B0ZWxvcy1xdWFkcm8ifSx7ImtleSI6IjViYWQxZmU0YTE0ZmUwMDEwMDhlM2EzNy93b3JrUGFja2FnZS81YmFlNTA5M2ExNGZlMDAxMDA4ZTQyNGMvZG9jdW1lbnQvNWJjNGE2ODM4ZWUwMGYwMTAwMDdlYmZlLzViYzRhNjgzOGVlMDBmMDEwMDA3ZWJmZS5KUEcifSx7IkNvbnRlbnQtVHlwZSI6ImltYWdlL2pwZWcifSx7IkNvbnRlbnQtRGlzcG9zaXRpb24iOiJpbmxpbmU7IGZpbGVuYW1lPWZpbGUxLkpQRyJ9LHsieC1hbXotY3JlZGVudGlhbCI6IkFLSUFKUElZUVRFTTIzNTM2Q1BRLzIwMTgxMDE1L3VzLXdlc3QtMi9zMy9hd3M0X3JlcXVlc3QifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWRhdGUiOiIyMDE4MTAxNVQwMDAwMDBaIn1dfQ==",
"x-amz-signature": "Redacted"
}
},
2条答案
按热度按时间edqdpe6u1#
在postman中使用put而不是post,并将文件名添加到url的末尾,如/foo. txt,并在s3.之后和. www.example.com之前添加区域amazonaws.com,同时在Authorization中删除该区域
示例:https://test.s3.us-east-1.amazonaws.com/test.csv
检查下面的链接了解详细信息https://christinavhastenrath.medium.com/testing-file-uploads-to-aws-s3-with-iam-user-credentials-in-postman-5026fbde3ca6
mbzjlibv2#
这是 Postman 应用程序本身的问题,我刚刚发送http请求到AWS与节点和x-amz-content-sha 256头似乎工作。
由于这个答案太简单和简短,我将在这里添加工作JS代码: