使用Express结合Google Function Framework文件上传失败问题排查
使用Express结合Google Function Framework时,文件上传功能完全失效。尝试过Multer、Formidable、Busboy及原生文件上传方法,这些方案在直接启动Express监听端口时都能正常工作,但结合Function Framework后全部失效。已尝试添加各类body解析器,问题依然存在。
各工具的具体表现如下:
- Multer:
req.file返回undefined - Formidable:从未进入
form.parse的处理逻辑 - 原生文件上传方法:
req.on('end')事件从未触发 - Busboy:抛出如下错误:
Error parsing the file upload: Error: Unexpected end of form
at Multipart._final (W:\workspace\playground\node_modules\busboy\lib\types\multipart.js:588:17)
at prefinish (node:internal/streams/writable:914:14)
at finishMaybe (node:internal/streams/writable:928:5)
at Writable.end (node:internal/streams/writable:843:5)
at onend (node:internal/streams/readable:946:10)
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Exception from a finished function: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
请求已正确设置 Content-Type 为 multipart/form-data; boundary=<calculated when request is sent>。
内容的提问来源于stack exchange,提问作者Nickname0222022022

