React Native:如何使用s3v4签名者将文件上传到s3

时间:2018-09-11 01:08:51

标签: react-native amazon-s3

我需要使用s3 v4登录React Native将文件上传到S3授权

请帮助我。

this.xhrrequest = new Request.XMLHttpRequest();
this._xhr.open("POST", s3url);
this._formData = new Request.FormData();
this._formData.append('file', path_to_file);
Object.keys(headers).forEach((header) => {
    return this.xhrrequest.setRequestHeader(header, headers[header]);
});
this._xhr.send(this._formData);

/*   heaaders i'm adding to xhrrequest data
* x-amz-acl private
* X-Amz-Content-Sha256 f2cd1.........34
* x-amz-date 20180911T004149Z
* Authorization AWS4-HMAC-SHA256
* Credential=Z.......I/20180911/ap-southeast-1/s3/aws4_request,
* SignedHeaders=host;x-amz-acl;x-amz-content-sha256;x-amz-date,
* Signature=de........5
* Content-type=multipart/form-data
*/

我收到错误消息

<?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>

0 个答案:

没有答案