I am testing the Javascript SDK SDK, I wrote simple code based on examples to get a list of files in a bucket. But I keep getting NetworkingError: Network Failureand can't find links to this error in the docs.
I also get the same error when trying getObject.
My code is:
AWS.config.update({
accessKeyId : 'myaccesskey',
secretAccessKey : 'mysecretkey'
});
AWS.config.region = 'us-west-2';
function list(){
var bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
bucket.listObjects(function (err, data) {
if (err) {
alert(err);
} else {
document.getElementById('status').innerHTML = 'Loaded ' + data.Contents.length + ' items from S3';
for (var i = 0; i < data.Contents.length; i++) {
document.getElementById('objects').innerHTML +=
'<li>' + data.Contents[i].Key + '</li>';
}
}
});
}
I have configured CORS to receive GET from all locations.
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
</CORSRule>
</CORSConfiguration>
What am I missing here?
source
share