I want to upload rather large files in a node.js/Firebase project. I am trying to understand if Busboy fits my need.
The example in the Busboy documentation ends with
req.pipe(busboy);
However this does not work in Firebase. It looks like you instead should use
busboy.end(req.rawBody);
That works for me (at least locally, under firebase serve
. However there is a difference, perhaps. In the example I mentioned above you have this:
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');
});
I expected to see several outputs from file.on("data", ...)
, but there is just one line for a 100 MB file. Does this mean that the whole file is kept in memory?
EDIT: The busboy.end(req.rawBody)
is from https://cloud.google.com/functions/docs/writing/http#multipart_data