我正在尝试向amazonS3预先签名的URL发送PUT请求.即使我只有一个PUT请求,我的请求似乎也会被调用两次.第一个请求返回200 OK,第二个请求返回400 Bad Request.
这是我的代码:
var req = {
method: 'PUT',
url: presignedUrl,
headers: {
'Content-Type': 'text/csv'
},
data: <some file in base64 format>
};
$http(req).success(function(result) {
console.log('SUCCESS!');
}).error(function(error) {
console.log('FAILED!', error);
});
Run Code Online (Sandbox Code Playgroud)
在400 Bad Request更详细的错误:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>InvalidArgument</Code>
<Message>Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified</Message>
<ArgumentName>Authorization</ArgumentName>
<ArgumentValue>Bearer someToken</ArgumentValue>
<RequestId>someRequestId</RequestId>
<HostId>someHostId</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)
我不明白的是,为什么它会回归400?什么是解决方法?