var express = require('express');
var bodyParser = require('body-parser');
var multiparty = require('multiparty');
var formidable = require('formidable');
var app = express();
...
app.use(bodyParser.raw({limit: 1024 * 1024 * 20}));
app.use(bodyParser.text({limit: 1024 * 1024 * 20}));
app.use(bodyParser.json({limit: 1024 * 1024 * 20}));
app.use(bodyParser.urlencoded({ limit: 1024 * 1024 * 20, extended: false }));
...
...
app.put('/fileupload', function(req, res, next){
console.log('FILE UPLOAD REQUEST');
var form = new formidable.IncomingForm();
//var form = new multiparty.Form();
form.parse(req, function(err, fields, files){
var file = files.file;
//var file = files.file[0]
/*... Logic to save file to disk...*/
...
console.log('Received new file');
});
});
This code is able to write files to disk with sizes smaller than 70-80kb. However when size is larger, the callback function of form.parse is not called(!) and there are no logs in the console. No error is thrown.
On my personal computer (OS X), I am able to write large files using PUT requests from the localhost. The problem occurs when the server is a remote computer running Ubuntu 14.04.
Prior to this problem, I had received the 'Request Entity Too Large' error in the Ubuntu server. After configuring nginx to 20Mb, the error stopped. The 20Mb limits on various bodyParsers are there just to show that I tried any configuration on that. Same goes for multiparty code that I commented out. Both Formidable and Multiparty won't parse those files.
What is happening here? How to parse files larger than ~80kb?
I have no idea why this happened, but I was able to transfer files of greater sizes using Busboy instead of Multiparty or Formidable