Closed katlimruiz closed 3 years ago
async (ctx) => {
await new Promise((resolve, reject) => {
asyncBusboy(ctx.req, {
onFile: async (fieldname, file, filename, encoding, mimetype) => {
// ...........
await saveFile();
resolve();
},
});
});
// continue...
};
Quick question. What if we have multiple uploads? Does promise resolve when the first file has been uploaded?
Currently, I'm using this approach. Is it redundant to store pending promises in the array?
const pendingUploads: Promise<any>[] = [];
const { files, fields } = await asyncBusboy(req, {
onFile: async (fieldname, file, filename, encoding, mimetype) => {
pendingUploads.push(s3.upload(filename, mimetype, file));
},
});
await Promise.all(pendingUploads);
console.log(`All Uploads Are Done!`);
res.send(200);
Hi
So I have a question I want to do an async/await pattern with the onFile custom handler.
I tried several ways and I dont' think I found one that works out.
I know this may be very simple, but I couldn't figure it out myself.