0
我试图上传一张照片到我的桶。我已经使用boto3生成了STS accesskey和secretykey和会话令牌。AWS javascript sdk无法上传到s3使用STS凭据
AWS.config.update({ accessKeyId: aws_cred.access_key, secretAccessKey: aws_cred.secret_key, sessionToken: aws_cred.session_token });
var unique_key = "files101/" + file.name;
var params = { Key: unique_key, ContentType: file.type, Body: file, ACL: 'public-read' };
bucket.upload(params, opts, function(err, data) {
if(err) {
console.log(err);
return 0;
}
});
我得到了仍然有此错误
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9999' is therefore not allowed access.
即使我已经添加ACL来我斗
我有这个CORS
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<ExposeHeader>x-amz-meta-custom-header</ExposeHeader>
<ExposeHeader>ETag</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
任何人都可以帮助我?谢谢
林不知道这个错误是关于我的CORS。使用我的实际密钥而不是STS生成的密钥时,我的上传工作正常。 – ParTidA