Hi all,
is there a reason why multer won't upload a file that's more than 1MB?
Here's how multer is set up in my node server (using coffee script):
storerOption =
destination: (req, file, cb) ->
cb null, './uploads'
filename: (req, file, cb) ->
cb null, (file.originalname.split(" ")).join('')
limitOption =
fileSize: 52428800
storer = multer.diskStorage storerOption
uploader = multer({ storage: storer, limits: limitOption })
app = express()
app.use(bodyParser.json({limit: '50mb'}))
app.use(bodyParser.urlencoded({limit: '50mb', extended: false}))
Did I get anything wrong?
There is no default file size limit, but there is a field size limit of 1MB. Is it possible that that is the one you are hitting?
Try adding fieldSize: 52428800 in addition to fileSize
@joques I'm having this exact issue. extending fieldSize and fileSize have no effect. Have you resolved your issue?
Same problem I can't exceed 1MB on a single() file upload despite setting 8MB:
const upload = multer({
dest: '/tmp/uploads',
limits: {
fieldSize: 8 * 1024 * 1024,
},
});
app.post('/messages/upload', upload.single('image'), async (req, res) => {
// never get here as multer rejects as 413 (too large)
}
fileSize not set as indicated as infinity, only fieldSize being limited to 1MB by default.
I can confirm that defining fileSize lower than 1MB will result in files being rejected if they exceed the specified size, but it seems impossible to have anything greater than 1MB.
6.1MB file I tested with:
If you are using nginx, you could try to add to your nginx config:
client_max_body_size 50M;
Default value is 1M
Is it possible to add a folder size limitation in multer . in my case i am trying to limit the upload by the size of destination . to calculate the folder size i used the package "get-folder-size"
I was getting this error too, but then I realized I was writing fieldSize: '50MB' instead of fieldSize: 50 * 1024 * 1024. The latter works for me. Got confused by multer's readme where the default fieldSize value is specified as 1MB.
I have added 50 * 1024 * 1024 to fileSize and to fieldSize and my image is uploaded but it is cropped almost all the bottom part and it ends up being 195.7kB long (not even 1MB) does someone have the same issue?
In my case, simply adjust the upload size of the Nginx server by specifying the http {client_max_body_size 100M;}
Same situation here. It turns out that it is the problem of Nginx's config. If you are running your app on AWS EB, here is a tutorial for setting the upload size on Nginx on AWS EB.
@joques is this still an issue for you ?
closing this issue as it's not a bug with multer
Most helpful comment
If you are using nginx, you could try to add to your nginx config:
client_max_body_size 50M;
Default value is 1M