Categories
JavaScript Answers

How to fix AWS missing credentials when trying send something to S3 Bucket in Node.js?

Spread the love

To fix AWS missing credentials when trying send something to S3 Bucket in Node.js, we call the config.update method.

For instance, we write

AWS.config.update({
  accessKeyId: "YOURKEY",
  secretAccessKey: "YOURSECRET",
  region: "sa-east-1",
});

const s3 = new AWS.S3();
const params = {
  Bucket: "makersquest",
  Key: "mykey.txt",
  Body: "HelloWorld",
};
s3.putObject(params, (err, res) => {
  if (err) {
    console.log("Error uploading data: ", err);
  } else {
    console.log("Successfully uploaded data to myBucket/myKey");
  }
});

to call update to update access key and secret key to connect to AWS.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.