如何在 express.js 中限制上传文件大小

问题描述:

我收到这个错误说

error:request entity too large 

上传大约 30MB 的视频时,

when uploading a video about 30MB,

这里是设置代码

app.use(express.bodyParser({
    uploadDir:'./Temp',
    maxFieldsSize:'2 * 1024 * 1024 * 1024 ',
}));

我不确定如何设置 maxFieldsSize 属性,需要一些帮助!!!

am not sure how to set the maxFieldsSize property, need some help!!!

Express使用connect中间件,可以通过以下方式指定文件上传大小

Express uses connect middleware, you can specify the file upload size by using the following

app.use(express.limit('4M'));

连接限制中间件