1

I need to get a list of buckets having the client accessKeyId and secretAccessKey. From the docs I understood that I have to update de configurations of AWS, create a new S3 object, then call on it the listBuckets() function with the callback.

So, here's my code:

AWS.config.update({
        accessKeyId: awsKey.identifier, secretAccessKey: awsKey.secret, region: awsKey.region,
        apiVersion: '2006-03-01'
    });

let s3 = new AWS.S3();
s3.listBuckets((response, data) => {
    console.log(response);
    console.log(data);
});

The problem is that I get: enter image description here

Thanks for your attention

Stefan Hariton
  • 347
  • 4
  • 19

3 Answers3

3

On the AWS Forums I got an answer that says it's impossible to do that, using amazon-javascript-sdk in the browser.

Here is the post: https://forums.aws.amazon.com/thread.jspa?threadID=179355&tstart=0

Stefan Hariton
  • 347
  • 4
  • 19
-2

You need to set permissions of file to public or any authorized user using any user define key while uploading files to amazon bucket. While Uploading files, there is option to set permissions. Thanks, Saurabh.

Saurabh Wankhede
  • 305
  • 1
  • 2
  • 6
-2

You probably need to configure CORS for your buckets. See AWS docs here: Configuring CORS for an Amazon S3 Bucket

MatteoSp
  • 2,940
  • 5
  • 28
  • 36
  • Ok, but I'm not trying in my example to access a specific bucket, I just want to see the names of buckets available in the specified account. So logically it has nothing to do with CORS settings of the bucket. If some bucket has no CORS enabled the it should not appear in the response for example, but i'm getting error in the request. – Stefan Hariton Apr 28 '15 at 12:35
  • I supposed, but I was wrong, that the AWS service that produce the list of buckets would evaluate CORS policies on each bucket and put into the list those the user could possibly access. But, as said, I was wrong. – MatteoSp Apr 28 '15 at 16:52