Skip to content

Handling multipart form-data (file-uploads) #386

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

Closed
harunhasdal opened this issue Jul 23, 2014 · 4 comments
Closed

Handling multipart form-data (file-uploads) #386

harunhasdal opened this issue Jul 23, 2014 · 4 comments
Labels

Comments

@harunhasdal
Copy link

Is there any guidance on which multipart parser to use with the generator for file uploads? Or a file upload endpoint generation option in the roadmap?

I've tried multer, multiparty, connect-busboy so far, but didn't have any success.

Having similar issues pointed out at #315

@JaKXz JaKXz added the question label Jul 24, 2014
@harunhasdal
Copy link
Author

Any of the above multupart parsers work, I needed to replace the express body-parser with the json and urlencoded ones.

I think this fix is already in place for the generator since the following commit. 8dc2f1e

@pasine
Copy link
Contributor

pasine commented Aug 4, 2014

Sorry @harunhasdal I have the same problem but I am not able to fix it neither with the new express configuration.
I am using multer and angular-file-upload.
The request looks fine (multipart-form, POST, parameters, etc.), but both body and files result empty on the server.
How did you fix it?

@harunhasdal
Copy link
Author

I ended up using busboy, not as middleware though. I used busboy events to process the uploaded files instead of using as middleware and have req.files.

I couldn't make the middleware (neither busboy nor multer) to work alongside body-parser. It's either one or the other in my experience, but then again i might be wrong.

Best thing to do is to debug the request to see how these middleware interact in case you need to use multer.

@pasine
Copy link
Contributor

pasine commented Aug 4, 2014

The problem is that body-parser included in the generator is ad old version.
Updating it to "~1.5.0" solved the problem and made it run smooth with multer.
I haven't tried it with other middleware, but I guess it would be the same for them.
I'll fix this and submit a PR.
Thanks @harunhasdal for point me out to the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants