我正在尝试将文件图像上传到我的 Amazon s3 存储桶,但不断收到 400 Bad request 错误。在挖掘时我发现错误代码是 Invalid Argument 但我不知道为什么我不断收到错误。
控制器.js
Upload.upload({
url: url,
method: 'POST',
fields : {
key: imageURI.name,
AWSAccessKeyId: key,
acl: 'public-read',
policy: policy,
signature: signature,
"Content-Type": imageURI.type != '' ? imageURI.type : 'application/octet-stream',
filename: imageURI.name
},
file: imageURI,
}).success(function(data, status, headers, config) {
console.log(data);
console.log(headers);
}).error(function (data, status, headers, config) {
});
cors配置
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://localhost:8100</AllowedOrigin>
<AllowedOrigin>http://staging.com.my</AllowedOrigin>
<AllowedOrigin>http://partners.com.my</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
这是我得到的错误报告
<Error>
<Code>InvalidArgument</Code>
<Message>Authorization header is invalid -- one and only one ' ' (space) required</Message>
<ArgumentName> Authorization</ArgumentName>
<ArgumentValue>YrRHhyr9uDF5SYntzyR3</ArgumentValue>
<RequestId>94E78E47B15BE7C5</RequestId>
<HostId>eR/Smasry6u1tE5b3DfrTLSGve3y4a/dZlYMLnBjcC2YhjUzskLzu3q85SYdfb9q0Ii09HCWcSI=</HostId>
</Error>
任何帮助表示赞赏。
谢谢