我正在使用ng-file-upload在我的角度应用程序中将文件发送到AWS-S3。
Upload.http({
url: '/presignedurl',
headers : {
'Content-Type': file.type
},
data: file
})
它给我403禁止错误说
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
AWS S3需要二进制/八位字节流,因此您可以在JavaScript中使用FileReader类将文件数据转换为二进制/八位字节流
以此替换您的代码
var reader = new FileReader();
var xhr = new XMLHttpRequest();
xhr.open("PUT", $scope.url);
reader.onload = function(evt) {
xhr.send(evt.target.result);
};
reader.readAsArrayBuffer($files[file]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句