node.js - express-fileupload - 如何允许大文件上传
问题描述
我正在使用 express-fileupload npm 包进行多部分文件上传。我需要上传多个文件,大小可以超过默认允许的 100kb 大小。我还为文件上传添加了以下配置以允许大文件,但没有运气。
const fileUpload = require('express-fileupload');
app.use(fileUpload({
limits: { fileSize: 50 * 1024 * 1024 },
}));
app.use(bodyParser.urlencoded({
extended: true
}));
// parse requests of content-type - application/json
app.use(bodyParser.json());
如果我缺少任何设置,请告诉我。
解决方案
好吧,我必须首先将 bodyParse.json() 用于正确处理 JSON 和任何其他形式的数据(urlencoded 和 multipart)。
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
推荐阅读
- powershell - Powershell中的问题不使用ReadKey
- node.js - Node.JS + Express 解析服务器上的 CSV 文件
- mysql - 如何使用子查询优化连接查询
- .net - ng2-pdfjs-viewer 打印功能打印整个 html 页面,而不是查看器中嵌入的 pdf 文档
- sql - Oracle SQL如何将具有不同数据的行合并为单行
- sql - 旋转数据库表
- apache-spark - 用于 Spark 结构化流的 Qubole Kinesis 连接器引发错误
- linux - 是否可以控制进程的调度策略
- java - 为什么我不能通过按“输入”来打破我的 while 循环
- python - scipy ver 0.18 scipy.interpolate.UnivariateSpline 如何处理不严格增加的值?