【发布时间】:2019-05-12 00:05:23
【问题描述】:
我想在 node.js/Firebase 项目中上传相当大的文件。我正在尝试了解 Busboy 是否符合我的需要。
Busboy 文档中的示例以
结尾req.pipe(busboy);
但这在 Firebase 中不起作用。看起来你应该改用
busboy.end(req.rawBody);
这对我有用(至少在本地,在firebase serve 下。但是也许有区别。在我上面提到的示例中,您有这个:
if (req.method === 'POST') {
let busboy = new Busboy({ headers: req.headers });
busboy.on('file', (fieldname, file, filename, encoding, mimetype) => {
console.log('File [' + fieldname + ']: filename: ' + filename + ', encoding: ' + encoding + ', mimetype: ' + mimetype);
file.on('data', (data) => {
console.log('File [' + fieldname + '] got ' + data.length + ' bytes');
});
我希望看到来自file.on("data", ...) 的多个输出,但是对于 100 MB 的文件只有一行。这是否意味着整个文件都保存在内存中?
编辑:busboy.end(req.rawBody) 来自https://cloud.google.com/functions/docs/writing/http#multipart_data
【问题讨论】:
标签: firebase pipe streaming google-cloud-functions busboy