Lesson 31 / 33
Streaming & Large Responses
Handle large file downloads and streaming responses efficiently.
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);
}