firebase 函数是否可以接收具有 multipart/form-data 内容类型的 http 请求?
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.