I have the following server code to receive multiple files at once using busboy:
.....
req.busboy.on('files', (files) => files.map((x) => {
let filename = x.filename;
let file = x.file;
let fieldname = x.fieldname;
file.on('data', (data) => {
//Work with current file
}
Then on the frontend I sent the request as below:
let requestBody = new FormData();
let data = {
body: postTextBody,
}
requestBody.append('data', data);
if (mediaObjects.length > 0) {
requestBody.append('files', mediaObjects.map((x) => x.file)); //Attach the multiple files here
}
axios.put(url,requestBody)....
I have a feeling this is not the right way to accept multiple files all at once with busboy because it seems not to be working.
What is the right way to accept multiple uploads with busboy?