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
I would try something like this:
var self = this;
var busboy = new Busboy({
headers: self.req.headers,
limits: {
files: 1,
fileSize: 500000
}
});
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
file.fileRead = [];
file.on('limit', function() {
//Clear variables
});
file.on('data', function(chunk) {
file.fileRead.push(chunk);
});
file.on('end', function() {
var data = Buffer.concat(file.fileRead, size);
// ... upload to S3
});
self.req.pipe(busboy);
});
Basically I added a new limit in the configuration of Busboy: fileSize: 500 * 1024
And I started listening limit event:
file.on('limit', function() {
//Clear vars
});