1

I have tried to make a post request, to my node server, with a base64 encoded file.

I get a PayloadTooLargeError: request entity too large exception, so i went to extend the payload limit, by Express 4 convention

app.use(bodyParser.json({limit: '100mb'}));
app.use(bodyParser.urlencoded({limit: '100mb', extended: true}));

Here is a console.log of the picture

however the problem still occurs, can anybody help me on why?

here are my global variables

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false}))
app.use(bodyParser.json({limit: '100mb'}));
app.use(bodyParser.urlencoded({limit: '100mb', extended: true}));
worc
  • 3,179
  • 3
  • 25
  • 31
Ating
  • 2,540
  • 1
  • 11
  • 39
  • Can you share a pastebin link with the string? – ninesalt Feb 15 '19 at 20:55
  • It's to large for a pastebin – Ating Feb 15 '19 at 21:01
  • a couple of questions stand out, the base64 string is definitely under 100MB? and is the bodyParser limit case-sensitive? 100 mega**b**its would be significantly smaller than 100 mega**B**ytes – worc Feb 15 '19 at 21:11
  • depending on the kind of error message you're getting, it might be another part of your stack: https://stackoverflow.com/questions/19917401/error-request-entity-too-large/40745569#40745569 – worc Feb 15 '19 at 21:24

1 Answers1

0

This is worked for me set the 'type' in addition to the 'limit' for bodyparser

var app = express(); 
var jsonParser = bodyParser.json({limit:1024*1024*10, type:'application/json'}); 
var urlencodedParser = bodyParser.urlencoded({ extended:true,limit:1024*1024*10,type:'application/x-www-form-urlencoded' });
app.use(jsonParser);
app.use(urlencodedParser);