QA
Intermediate LevelExpress JS

How do you process massive multi-gigabyte file uploads in Express using Busboy streaming?

❓ Interview Prompt: Explain non-buffering file upload streaming, Busboy event-driven parser, piping request sockets to storage, and avoiding RAM spikes.

Standard file upload tools buffer entire files into memory or temporary disk space before route execution. For multi-gigabyte files, this causes server RAM spikes!

Busboy Streaming:

'busboy' parses incoming 'multipart/form-data' streams chunk-by-chunk on the fly, piping file streams directly to cloud storage (AWS S3) or disk without buffering in Node.js RAM!

Code Implementation Example

javascript
import express from 'express';
import busboy from 'busboy';
import fs from 'fs';

const app = express();

app.post('/api/stream-upload', (req, res) => {
  const bb = busboy({ headers: req.headers });

  bb.on('file', (name, file, info) => {
    const saveTo = `./storage/${info.filename}`;
    file.pipe(fs.createWriteStream(saveTo)); // Stream directly to disk!
  });

  bb.on('close', () => res.json({ status: 'Upload complete' }));
  req.pipe(bb);
});
💡Streaming multi-gigabyte file uploads to disk using busboy.
🎯 Interview Key Takeaway

Use Busboy to stream multipart file uploads directly to storage without buffering in Node.js RAM.

#Busboy#Streaming#File Uploads#Intermediate
Back to all Express JS Questions→

More Express JS Interview Questions

Beginner LevelExpress JS

What is Express.js and how does the middleware pipeline work?

Beginner LevelExpress JS

What is the difference between req.params, req.query, and req.body?

Beginner LevelExpress JS

How does express.Router() work for building modular route controllers?