Interview frequency: …
Short answer
Pipe the HTTP request stream (req) directly through a pipeline to a disk file or cloud storage (S3) as a multipart stream as its chunks arrive.
Explanation
Loading the entire file into memory can crash the server as soon as a large file is uploaded. The right design treats the request body req as a Readable Stream, passes it to a multipart parser, and routes it directly to the final storage destination.
Code example
await pipeline(req, fs.createWriteStream("file.bin"));Common mistakes
- Storing the file contents in in-memory variables before writing them to disk.