NestJS · Senior · Question 53 of 75
How do you stream a large file download in Nest without loading it into memory?
- 1Read the file with
readFileSyncand return the Buffer - 2Base64-encode it in JSON
- ✓Correct answer: Return a
StreamableFilewrapping a readable stream, so Nest pipes it to the response
Explanation
StreamableFile works with both Express and Fastify and keeps interceptors working.