1

I'm uploading a file using express into a MongoDb. All is working fine, but now I'm trying to set a size limit. Setting busboy configuration as busboy site declares:

 var busboy = new Busboy({ headers: req.headers,  limit: { files: 1, fileSize: 50000 }  });

then:

file.on('limit', function(data) {                                               
     console.log("LIMIT");
});

By the way, I can try to find a workaround by stopping everything when the data chucks add up to the limit size.

file.on('data', function(data) {                                          
   fileSize+=data.length;
    if (fileSize>50000){
        //limit reached 
   }                         
});
Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57
uajov6
  • 413
  • 7
  • 13

1 Answers1

7

The limit config option is limits and not limit. Change that and it should work.

mscdex
  • 104,356
  • 15
  • 192
  • 153