I do have a one time running JS file, which is running as a command line tool. But not as a REST server.
The issue I have is that I do have the following function which accepts the arguments and uploads a file to a specified S3 bucket.
const uploadToAWSS3Bucket = (stream, fileName, bucketName) =>{
const params = {
Bucket: bucketName || '',
Key: fileName,
Body: stream
};
console.log(`Using Bucket ${bucketName} for uploading the file ${fileName}`);
return s3.upload(params, (err, data) => {
if (err) {
console.log(err);
}
console.log(data.stringify);
console.log(`File uploaded successfully. ${data.Location}`);
console.log(`Finished uploading the file ${fileName} to Bucket ${bucketName}.`);
}).promise();
// await sleep(80000);
};
This is called/implemented by the following method.
(async()=>{
const result = await uploadToAWSS3Bucket(stream, 'filename.json', 'mybucketname');
console.log(result);
});
However, the node index.js command exits with giving out a commandline output and it appears that the file upload never gets completed because of that.
Anything that I am missing or any trick that would work on this case?