【发布时间】:2017-02-05 19:15:54
【问题描述】:
我已经完成了 stackoverflow 中提到的所有解决方案,但我无法解决错误。我在 S3 中列出我的所有存储桶时收到 403 错误,并且在列出特定存储桶中的对象时也收到相同的错误。
我在 S3 上更改了我的 CORS 配置,如下所示
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
但没有白费。我的代码如下所示
s3=new AWS.S3({ accessKeyId: userId ,secretAccessKey: password, sslEnabled: false, s3ForcePathStyle: true});
function listBuckets(){
$("#function").empty();
$("#function").hide();
$("#listObjectsOption").hide();
$("#uploadFile").hide();
s3.listBuckets(function(err,data){
console.log(data);
}
我使用的浏览器是谷歌浏览器。
任何人都可以请建议。我得到的错误是
aws.js:8167 OPTIONS
XMLHttpRequest cannot load http://s3.amazonaws.com/. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.
我也无法创建存储桶或采取任何行动。
【问题讨论】:
标签: javascript amazon-web-services amazon-s3 cors