Sign in to keep reading
βHandling Large Blobsβ is free with an account. Your progress and bookmarks follow you across devices.
Sign in to continueNEW: ML Mock & Coaching with a 20+ year experience coach. Save $20 on sessions for Premium.ML Mock & Coaching now available
NEW: ML Mock & Coaching with a 20+ year experience coach. Save $20 on sessions for Premium.ML Mock & Coaching now available
Upload and serve large files efficiently using pre-signed URLs, multipart uploads, CDN delivery, and post-upload processing pipelines.
βHandling Large Blobsβ is free with an account. Your progress and bookmarks follow you across devices.
Sign in to continueEvery non-trivial application eventually needs to handle large files. In the File System question, users sync gigabyte-sized folders. In Slack, people drop images and videos into chat channels. In Top-K Videos, creators upload raw footage that needs to be transcoded before anyone can watch it. The challenge is always the same: how do you move hundreds of megabytes (or more) without crushing your servers?
The fundamental insight is simple but powerful: your application server should coordinate file transfers, not mediate them. A 500 MB video upload that passes through your API server consumes a worker thread for minutes, eats memory, and starves other requests. The fix is to get the file off your server's back entirely.
The naive approach is straightforward: the client sends the file to your API server, which then forwards it to object storage (S3, GCS, Azure Blob). This means the file travels through your server twice β once in, once out. For a 500 MB file, that is a full gigabyte of bandwidth consumed on your server, plus a worker thread blocked for the entire duration.
With just a few concurrent uploads, your API server runs out of memory or threads. Meanwhile, the actual work your server needs to do β signing URLs, saving metadata β takes milliseconds.
A pre-signed URL is a temporary, authenticated URL that lets a client upload (or download) directly to object storage without any credentials baked into the client. Your server generates the URL using its own cloud credentials, embeds restrictions (file size limit, content type, expiry time), and hands it to the client. The client then talks to S3 directly.
Here is the complete flow:
The sequence breaks down into seven lightweight steps:
Your server's total work: two small HTTP handlers and one database write. The heavy lifting β transferring hundreds of megabytes β happens between the client and S3.
See it in practice: The File System question is the direct application of this pattern β you design upload and download flows with pre-signed URLs and metadata management. In Slack, file attachments and media sharing in chat channels use pre-signed URL uploads for user-generated content. In ChatGPT, file uploads for context documents follow the same pattern.