Reputation: 7470
I have a simple POST to a /upload
express endpoint. Small files work just fine, however, anything above 2mb gives me the following error:
413 (Request Entity Too Large)
Is there something I am missing that needs to be added to work? Here is what my code looks like:
const { Router } = require('express')
const fileUpload = require('express-fileupload')
router.post('/upload', fileUpload(), function (req, res) {
console.log('I am never reached')
let uploadFile = req.files.file
const fileName = req.files.file.name
// do stuff
}
What am I doing wrong? Did I miss another middleware before that? I should also note that in fileUpload
, I have tried to put as:
fileUpload({
limits: { fileSize: 50 * 1024 * 1024 },
})
But it didn't help. What else could be wrong?
Edit: This is my fetch code in case that may also help:
const data = new FormData()
data.append('file', file, file.name)
return isomorphicFetch(`/upload`, {
method: 'POST',
body: data
})
Thanks!
Upvotes: 0
Views: 2341
Reputation: 56
I've spent some hours trying to figure it out in my side.
Regardless the configuration that I was following the I always was getting the 413 as status code and I realized the problem was in NGINX Ingress in my kubernetes cluster, then I added:
...
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 16m
This was enough to solve it.
I hope you it can help who else get this issue as well.
Upvotes: 2
Reputation: 49
you can try this in the main file of your application:
const express = require('express');
const app = express();
app.use(express.urlencoded({extended: false, limit:'100mb',parameterLimit:1000000 }));
Upvotes: 0