Using JavaScript and AWS SDK to access S3 Bucket without Credentials


I am attempting to use the AWS SDK to conveniently retrieve data from an S3 bucket without having to provide credentials.
I have a directory of files and I want to be able to add files/remove files/rename files within that directory without having to update my code.
Right now I have just been trying to make sure that I can retrieve the ListObjects, at which point I can parse the response to get the Keys.

<script src=""></script>
<reference types="aws-sdk" />
window.onload = function loadFilenames() {
        var s3 = new AWS.S3();
        var params = {  
            Bucket: "bucketname",
            Prefix: "fileslocation/"
        s3.listObjectsV2(params, function(err, data){
            if (err) console.log(err, err.stack);
            else console.log(data);

When I do this I get the error: CredentialsError: Missing credentials in config...
Because I want a visitor to the website to be able to see this data, I don't want to have to create an IAM user and pass the credentials. Is there a way to do this, or am I barking up the wrong tree? Thanks!

asked 4 years ago755 views
1 Answer

I ended up being able to accomplish the same thing by making an Ajax request and parsing the XML response.

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions