moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 119 forks source link

Multipart fields issue #277

Closed ydanneg closed 2 years ago

ydanneg commented 2 years ago

Hi.

There is an issue when form-data fields are provided after actual file/blob data. These fields are not available within a triggered action as a '$multipart' meta data.

Please see my branch where I marked affected places and modified (actually fixed) test code to show an issue.

https://github.com/ydanneg/moleculer-web/commit/4584d2cb4931416a31413d7d8e8fbcc834e8edaf

PS. I'm not JS developer, so hope you will handle this issue by yourself guys.

icebob commented 2 years ago

I think, we can't fix it, because the processing of multipart is sequential. So you can't access to the field until you fetch out all file streams. But for fetching the GW should send it to the service. So better if you put the field before the file.

Another solution is if you don't use the busboy multipart handling module, and use e.g. formidable which saves all files into files on the GW side. And after all fields are received, you can send the files to the services as streams.

ydanneg commented 2 years ago

thanks for reply. i understand it's the problem for streaming files forward. but it's not my case. so i found that multer fits perfect for my case. i suggest you too make an accent on this behaviour in your documentation.

thank you