Recipes
Overview
Task-shaped walkthroughs — the common media jobs (avatars, galleries, browser uploads, serving, multi-disk) and the extension points (custom driver, custom store, testing).
The concepts pages explain the model; these are the jobs people actually sit down to do. Each one is self-contained — start from the closest match and adapt.
Common jobs
| Recipe | What it covers |
|---|---|
| Single-file avatar | one file per owner, replacing the previous one, with a cropped variant |
| Gallery with thumbnails | an ordered collection, reordering, and lazy thumbnails |
| Resumable uploads from the browser | tus and presigned direct-to-S3, and when each is the right one |
| Serving files | public URLs, signed URLs, and streaming through your own controller |
| Multiple disks | routing collections at different backends, and moving files between them |
Files that aren't media
A report, a cache file, a file another library reads: use @nestjs/storage directly (Storage, @InjectDisk(), serveFile(), uploadToDisk()). See File storage in the NestJS docs; nestjs-media adds nothing there.
Extending it
| Recipe | What it covers |
|---|---|
| Writing a custom disk | subclass @nestjs/storage's StorageDisk (NestJS docs), then check it with describeMediaDiskConformance from -testing |
| Writing a custom store | the MediaStore SPI, plus the optional query methods the dashboard needs |
| Testing your media code | InMemoryDisk, the in-memory stores and the conformance suites |