Node js request entity too large with multer upload

后端 未结 2 985
天涯浪人
天涯浪人 2021-02-09 18:20

well I\'ve tried different ways to upload a 200k file increased the limit changed parameters, did everything I changed the multer. Fucei everything I knew what I read in the sta

相关标签:
2条回答
  • 2021-02-09 19:00

    In my case, after setting the limit @ node.js (webapp) var express = require('express'); var app = express(); var bodyParser = require('body-parser'); app.use(bodyParser.json({limit:'50mb'})); app.use(bodyParser.urlencoded({extended:true, limit:'50mb'}));

    I also (most important) had to set up the limit @ nginx (webapp reverse proxy) # Max upload size. client_max_body_size 50M;

    0 讨论(0)
  • 2021-02-09 19:01

    I can't tell by all of your code but just by looking at the error, you should be able to set the body post size with the following:

    https://www.npmjs.com/package/multer#limits

     multer({
        storage: storage,
        limits: { fileSize: maxSize }
     })
    

    If that doesn't solve your issue, bodyParser also has a limit. It's options can be found:

    https://github.com/expressjs/body-parser#limit

    bodyParser({limit: '4MB'});
    
    0 讨论(0)
提交回复
热议问题