Lesson 32 / 34

Streaming & Large Responses

Stream large files and responses with StreamableFile instead of loading them into memory.

By · 15 years in web development · Updated 1 Oct 2026

Stream a file

Use StreamableFile or Express' response object to stream large files without loading into memory.

import { StreamableFile } from '@nestjs/common';
import { createReadStream } from 'fs';

@Get('download')
downloadFile(): StreamableFile {
  const file = createReadStream('large-file.zip');
  return new StreamableFile(file);
}