首页 > 解决方案 > 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());

如果我缺少任何设置,请告诉我。

标签: node.jsexpressfile-uploadmultipartform-data

解决方案


好吧,我必须首先将 bodyParse.json() 用于正确处理 JSON 和任何其他形式的数据(urlencoded 和 multipart)。 app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true }));


推荐阅读