Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check fields before storing file #244

Closed
halkeye opened this issue Oct 10, 2015 · 1 comment
Closed

Check fields before storing file #244

halkeye opened this issue Oct 10, 2015 · 1 comment

Comments

@halkeye
Copy link

halkeye commented Oct 10, 2015

So if I understand how multer works correctly, it parses the multipart data, then passes it to fileFilter, then the storage engine.

Is there a way to inject a step before storage engine to confirm other non file fields are defined properly before files are stored? fileFilter doesn't get called for the text fields.

I'm thinking I'll have to a memory storage, then pass that blob onto wherever I actually want it stored.

@LinusU
Copy link
Member

LinusU commented Oct 11, 2015

When the fileFilter is triggered, any text fields that have been parsed up to that point will be available in req.body. Multer cannot give any guarantees on the order that the web browser sends the fields thought, so the fields you want to check might or might not be available at that time.

This has come up a number of times before, e.g. #146 where a workaround is outlined.

@LinusU LinusU closed this as completed Oct 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants