Is it possible for firebase function to receive http request with multipart/form-data content-type?
Asked
Active
Viewed 3,467 times
4
-
1See also https://stackoverflow.com/questions/47242340/how-to-upload-a-file-using-express-on-firebase-cloud-functions/47319614#47319614 – Doug Stevenson Nov 16 '17 at 01:31
1 Answers
1
Yes but Google Cloud Functions doesn't have the middleware for handling those requests built in by default (see the body-parser docs for more info).
I haven't tested it but formidable looks popular.
If you are uploading files however, I'd recommend you write them directly to Cloud Storage for Firebase instead. With Cloud Storage you'll get niceties afforded by our SDKs, you'll save bandwidth/time (since you'll be uploading it directly to the storage engine), and you get the benefit of our built-in rules engine. From there you could have a functions.storage.object().onChange(event => {})
listener in Cloud Functions which would trip whenever a new file was successfully uploaded.

James Daniels
- 6,883
- 4
- 24
- 28
-
5In many cases adding directly to storage from the client code is not feasible. It is usually preferable to keep all API keys on the server, in this case in a Cloud Function, and to provide an API layer. – Shane O Sullivan Jul 27 '19 at 06:18