1

I'm a bit confused with Busboy module. I don't understand where it takes file data to stream as it accepts only request headers as parameter?! Take a look on example from docs:

var busboy = new Busboy({ headers: req.headers });
busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {
   //...
   // btw file is ReadableStream!
});
Kosmetika
  • 20,774
  • 37
  • 108
  • 172

1 Answers1

2

It gets the request body piped to it, see the example:

req.pipe(busboy);
robertklep
  • 198,204
  • 35
  • 394
  • 381
  • yeah, now I see, thanks, but internally all request instance will be available then? – Kosmetika Jul 09 '15 at 09:08
  • @Kosmetika just the headers and the body are enough for it to do its magic, it doesn't appear to need anything else from the request object. – robertklep Jul 09 '15 at 09:09
  • 1
    I just leave this link here - https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback_1 if somebody will be confused on the streams topic like me. It's a bit not obvious from the quick look into docs. – Kosmetika Jul 09 '15 at 09:30
  • when uploading a 10 gb file from my frontend app (reactjs) to my nodejs server that uses busboy, does the file gets stored anywhere in the nodejs server harddisk as a tmp file? – Phantom007 Sep 09 '21 at 07:33
  • @Phantom007 I don't think so, it's a streaming parser. – robertklep Sep 09 '21 at 12:02