How to limit upload file size in express.js

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'));

Connect Limit middleware

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.