I have gone through all solutions mentioned in stackoverflow but yet I am not able to solve the error .I am receiving 403 Error while listing all my buckets in S3 and also getting the same error while listing objects in a particular bucket .
I have changed my CORS config on S3 as below
<?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>
But to no vain .My code is like below
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);
}
The Browser which I am using is Google Chrome.
Can anyone please suggest. Error Which I am getting is
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.
Also I am not able to create Bucket or take any actions.
Probably has nothing to do with CORS because you are using the API here. The user whos access/secret keys you use probably doesnt have the necessary permissions. listBuckets needs a policy like this:
{
"Sid": "Stmt1472023667000",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": [
"*"
]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.