AWS S3 Javascript in error browser

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?

+4
source share
2 answers

A list of regions and endpoints can be found here:

http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

I use the same code. Check out the code below:

<script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc4.min.js"></script>

, , . - Network Failure, , script, , , .

.

+3

SDK , ('us-west-2'). S3 , , ( myBucket.s3-us-west-2.amazonaws.com).

, ? , , , " ", 'us-east-1' SDK.

+1

All Articles