2

I am trying to upload file in aws-s3 but it shows me some error like enter image description here

NodeCode:

const AWS = require('aws-sdk'); const uploadFile = async (file) => { const s3 = new AWS.S3({ accessKeyId: "<AWSS3_AccessKey>", secretAccessKey: "<AWSS3_SecretKey>", region: "ap-south-1" }); const params = { Bucket: "test123", // pass your bucket name Key: file.name, //filename Body: file.data, //data }; s3.upload(params, function(s3Err, data) { if (s3Err) throw s3Err //console.log(`File uploaded successfully at ${data.Location}`) }); }; var files = []; var fileKeys = Object.keys(req.files); fileKeys.forEach(function(key) { var file = req.files[key]; files.push(file.name); uploadFile(file); }); 
3
  • Some time ago I answered a question, demonstrating how to configure an instance of s3 and upload multiple files. See in SO - Answer. Commented Dec 4, 2018 at 11:46
  • @AndersonMendes, above code was working previously but now it is not working. Commented Dec 4, 2018 at 11:53
  • I understand, I found this issue about a possible cause but still no solution. Commented Dec 4, 2018 at 12:01

1 Answer 1

2

your aws cli config file in not configured properly the location of config file is

at ~/.aws/config on Linux, macOS, or Unix, or at C:\Users\USERNAME.aws\config on Windows.

you need to setup this file before you use any sdk to call aws services i'm posting a link which will guide you how to setup aws cli in different operating systems

Setup AWS CLI

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.