I\'m using busboy, writing my uploaded file to a buffer and performing some validation on it (width, height and filesize). I can\'t for the life of me figure out how to abo
Ok, so I had the same problem and I solved it with file.resume();
var fstream;
req.busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
// Validate file mimetype
if(mimetype != 'image/png'){
file.resume();
return res.json({
success: false,
message: 'Invalid file format'
});
}
// Upload
fstream = fs.createWriteStream(__dirname + '/tmp/' + timestamp + filename);
file.pipe(fstream);
fstream.on('close', function () {
return res.json({
success: true
});
});
});
req.pipe(req.busboy);