Multer: How to catch the error raised by the options limit.fileSize?

Created on 7 Nov 2015  路  1Comment  路  Source: expressjs/multer

limits: {
    fieldNameSize: 100,
    fileSize: 1024*1,
    files: 1,
    fields: 100
  }

I use the options limit , and then upload a file which fileSize > 1024 bytes, but I don't know how to catch the error. Also the the file in fileFilter(req, file, cb), only has 4 properties

fieldname
originalname
encoding
mimetype

I couldn't use the property fileSize to filter the file.

{ [Error: File too large] code: 'LIMIT_FILE_SIZE', field: 'image', storageErrors: [] }
Error: File too large

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tonghae picture tonghae  路  4Comments

edi picture edi  路  4Comments

bpetty-formfast picture bpetty-formfast  路  3Comments

tjabdoullah picture tjabdoullah  路  4Comments

BlueOctober picture BlueOctober  路  3Comments