1

I am using latest version of busboy, node 18 and expressjs.

When I upload 10 txt files it finishes successfully but if:

  • I have two docx/rar files only once "file" event is triggered and it is stuck same happens if I mix docx/rar file with txt files and I can not figure it why?

In the frontend:

var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', uploadUrl, true);
xmlhttp.onreadystatechange = function () {
//handle status
};

var formData = new FormData();

formData.append('size', calculateSize(files));
formData.append('numberOfFiles', files.length);
for (let i = 0; i < files.length; i++) {
        console.log(`Append file:${file.name}`);
        formData.append('files', file);
}

xmlhttp.send(formData);

backend:

var busboy = new Busboy({ headers: req.headers });

busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
console.log("In bus boy");
});
busboy.on('field', function(fieldname, val, fieldnameTruncated, valTruncated, encoding, mimetype) {
      console.log('Field [' + fieldname + ']: value: ' + inspect(val));
});
}
Crowley
  • 169
  • 6

0 Answers0