[英]File Upload to s3 bucket via NodeJS Console app via aws-sdk doesnt get completed
I do have a one time running JS file, which is running as a command line tool.我确实有一个一次性运行的 JS 文件,它作为命令行工具运行。 But not as a REST server.
但不是作为 REST 服务器。
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.我遇到的问题是我确实有以下 function 接受 arguments 并将文件上传到指定的 S3 存储桶。
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.但是,
node index.js
命令退出并给出命令行 output ,因此文件上传似乎永远不会完成。
Anything that I am missing or any trick that would work on this case?我遗漏的任何东西或适用于这种情况的任何技巧?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.