I'm trying out the AWS Javascript SDK, I wrote a simple code based on the examples to get the list of files in a bucket. But I keep getting NetworkingError: Network Failure, and can't find any references to this error in the docs.
I also get the same error when I try a getObject.
My code:
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 configured CORS to accept GET from all locations.
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
</CORSRule>
</CORSConfiguration>
What am I missing here?