我需要使用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>