问题
I am getting a presigned url from aws and using it to request(PUT) a zip file. I get signature does not match.
when getting presigned url:
const params = {
Bucket: myBucket,
Key: myKey,
Expires: 60*60,
ACL: '**-**-**',
ContentType: 'application/x-zip-compressed'};
when requesting:
const formData = new FormData();
formData.append('file', file);
formData.append('filename', file.name);
fetch(url, {
method: 'PUT',
headers: {
'Content-Type': 'application/x-zip-compressed',
},
body: formData
})
回答1:
Whatever ACL
value you're using in the signature needs to also be sent in the request headers, as 'x-amz-acl': '**-**-**'
.
Note also that an S3 PUT
does not expect FormData
-- it expects the body
to contain only the raw bytes of the object. This isn't the cause of the error, but once you correct the signature error, you'll need to change this, too, in order to get a valid, usable upload.
来源:https://stackoverflow.com/questions/54660048/s3-presigned-url-multipart-formdata-upload-errsignature-does-not-match