s3 presigned url multipart formdata upload err:signature does not match

旧城冷巷雨未停 提交于 2019-12-25 03:13:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!