expressjs/multer

Wrong error sometimes for file that's too large?

Open

#405 aberto em 6 de out. de 2016

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (1.043 forks)batch import
futurehelp wanted

Métricas do repositório

Stars
 (11.136 stars)
Métricas de merge de PR
 (Mesclagem média 9d 11h) (7 fundiu PRs em 30d)

Description

Having trouble reproducing this, but for a while today I was receiving a confusing error, 'Unexpected field' (a.k.a. LIMIT_UNEXPECTED_FILE). Searching Stack Overflow I found that this error was mostly caused by a mismatch between the "name" string in the form and the one in my Express route. But that wasn't it because they were both called "image."

I tried re-installing the module but still got the same error. Then I switched to a much smaller file and Multer started working again without the "unexpected field" error. Then, to test my theory I tried uploading a large file, only this time to receive the correct "request entity too large" error.

Also I wonder if there has been discussion of providing an easier-to-understand, separate error message like

"Error: Multer requires a 'name' attribute that matches the one in the route, but received: 'picField'"

Seems like it would save a lot of time for folks...

Guia do colaborador