I have the following functions which takes in a zip stream, unzips and uploads it to S3:
export const unzipAndUpload = async (stream) =>
stream
.pipe(unzipper.Parse())
.on("entry", async entry => {
await uploadToS3(
await entry.buffer(),
entry.path
);
console.log("ENTRY", entry.path)
entry.autodrain();
})
.on("finish", () => {
console.log("FINISH")
})
.promise();
Currently FINISH
gets called first and then the ENTRY
logs continue to print out.
How can I really tell if the stream is really finished? uploadToS3
requires a buffer so I need to await
and do certain things synchronously - this is fine. However, how can I be sure all files have been uploaded?
Thanks in advance!