Media Pipelines: Uploads, Storage, and Cost
The plumbing behind multimodal features: direct uploads, validation, resizing, object storage, async processing, and keeping media costs predictable.
Every multimodal feature in this module started with "the user uploads a file", and every one quietly depends on plumbing that has nothing to do with AI. Where does the file go? What if it's 2 GB, or a renamed executable, or a photo with the user's home address in its metadata? What happens when a hundred people upload voice notes at once? And why did the AI bill triple the week a customer started attaching 4K screen recordings?
This lesson is about that plumbing. You'll build Deskmate's media pipeline: uploads that go straight to object storage, validation that trusts bytes rather than file names, derivatives sized for people and for models, background processing that survives failures, and the cost controls that keep multimodal features predictable.
The shape of a media pipeline
A production media pipeline has the same stages whatever the media type:
- Request an upload. The browser tells your server what it wants to upload. The server checks permissions and limits, records a pending upload, and returns a short-lived URL.
- Upload directly to storage. The browser sends the file straight to object storage, never through your app server.
- Validate the real file. A background worker reads what actually arrived and checks it: type, size, dimensions, duration.
- Make derivatives. Thumbnails for the UI, a display version, and a version sized for the AI model. Strip sensitive metadata.
- Run the AI step. Captioning, transcription, embedding, extraction: whatever the feature needs, on the derivative.
- Mark it ready and notify the UI.
Each stage records its progress on a media row in your database (awaiting_upload, processing, ready, failed), so the UI always knows what to show, and a failure at any stage is visible and retryable instead of a file silently going missing.
Two principles run through all of it. The client is never trusted: the declared type, size, and file name are hints, and the real checks happen on the bytes. And AI steps run on derivatives, not originals, because the original is usually far bigger than any model needs.