Issues Uploading JSON to s3 using node.js
I don't have enough reputation to comment, but for what its worth with the new aws-sdk version you can use the promise chain when posting the JSON instead of a callback:
try{
await s3.putObject({
Bucket: 'currenteventstest',
Key: 'users.json',
Body: JSON.stringify(users),
ContentType: 'application/json; charset=utf-8'
}).promise();
}
catch(e){
throw e
}
Adding a callback function fixes the problem:
s3.putObject({
Bucket: 'currenteventstest',
Key: 'users.json',
Body: JSON.stringify(users),
ContentType: "application/json"},
function (err,data) {
console.log(JSON.stringify(err) + " " + JSON.stringify(data));
}
);