i got this error says
error:request entity too large
when uploading a video about 30MB,
here is the setting code
app.use(express.bodyParser({
uploadDir:'./Temp',
maxFieldsSize:'2 * 1024 * 1024 * 1024 ',
}));
am not sure how to set the maxFieldsSize property, need some help!!!
Express uses connect middleware, you can specify the file upload size by using the following
app.use(express.limit('4M'));
// Comment sart
// app.use(express.bodyParser({
// uploadDir:'./Temp',
// maxFieldsSize:'2 * 1024 * 1024 * 1024 ',
// }));
// Add this code for maximun 150mb
app.use(bodyParser.json({limit: '150mb'}));
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
limit: '150mb',
extended: true
}));
// I did it Okay. Goood luck
app.use(express.limit('4mb'));
But you must make sure you add this line above the below,
app.use(express.bodyParser());
or
app.use(express.json());
app.use(express.urlencoded());
depending on which version you are using.
I'm using Express 4. I tried numerous app.use() statements, including the non-deprecated ones listed on this thread, but none of them worked.
Instead, it turned out I only needed to add one line to index.js to change the maxFileSize option in the Formidable module:
// create an incoming form object
var form = new formidable.IncomingForm();
// ADD THIS LINE to increase file size limit to 10 GB; default is 200 MB
form.maxFileSize = 10 * 1024 * 1024 * 1024;
Source: Comments from here.
var upload = multer({ storage : storage2, limits: { fileSize: 1024 * 1024 * 50 } });
correct format for increasing file uploading size with multer in nodejs
来源:https://stackoverflow.com/questions/13374238/how-to-limit-upload-file-size-in-express-js