Uploading large files reliably

Chunked, resumable, direct-to-storage uploads: how to move gigabytes over unreliable networks without tying up your servers.

On the roadmap:Staff Engineer · step 4: Real-time at scale

Lesson 17 of 18 · 9 min read · quiz · exercise

Why large uploads are hard

A 5 GB file on a normal request has many ways to fail:

  • A single long connection dies on a flaky network, losing everything.
  • Timeouts in load balancers and proxies cut off long requests.
  • Your application servers are tied up carrying bytes, and memory or disk fills.
  • A failure at 99% means starting again.
  • Users want a progress bar and the ability to pause and resume.

The design in one picture

Figure SDA-RWS-17-1 · Chunked, resumable upload flow · © forcsguy.com

Before: upload through your server

After: upload straight to storage

What changed

  • Your servers no longer carry large files
  • A failed chunk is retried, not the whole file
  • Pre-signed URLs keep storage private

Step by step

  1. Initiate. The client tells the API the file name, size and type. The API checks permissions and limits, and creates an upload session with a unique id.
  2. Direct to storage. The API returns pre-signed URLs: short-lived, scoped links that let the client upload straight to object storage. Your servers never carry the file.
  3. Chunk. The client splits the file into parts (for example 5 to 100 MB; object stores typically accept thousands of parts per object) and uploads them, in parallel.
  4. Verify. Each part carries a checksum (MD5, CRC32C or SHA-256). The storage service or your server checks it, and a bad part is simply re-sent.
  5. Resume. The session remembers which parts are done. After a drop the client asks which parts exist and sends only the missing ones. Open protocols such as tus standardise resumable uploads.
  6. Complete. The client sends the list of parts; storage assembles the object.
  7. Post-process asynchronously. An event triggers virus scanning, type verification, thumbnails or transcoding, and metadata updates. The user sees "processing" until it finishes.

Checking each part

When a part arrives, the store replies with a checksum tag. The client keeps the list of part numbers and tags, and sends it with the final "complete" request, so the store can verify and assemble exactly the parts you meant, in order. A failed part is re-sent alone; assembly of a very large object can take a few minutes, so treat "complete" as asynchronous from the user's point of view.

Smart extras

  • Deduplication: hash the file (or chunks) on the client first. If the content already exists in storage, skip the upload entirely and just add a reference (as in cloud file storage services).
  • Parallelism and adaptive chunk size: larger parts on fast networks, smaller on poor ones.
  • Compression for compressible data before upload.
  • Upload acceleration: send to the nearest edge location, which forwards over the provider's backbone.
  • Progress and cancellation: the client tracks bytes per part; cancelling aborts the session.

Safety and cost

  • Limit size, type and number of concurrent uploads per user, and expire pre-signed URLs quickly.
  • Validate on the server, not only in the client: check file type by content, scan for malware, and store uploads in a quarantine area until cleared.
  • Use lifecycle rules to delete incomplete multipart uploads after a few days, since unfinished parts cost money until removed.
  • Encrypt in transit and at rest; do not let user-provided names choose storage paths.
  • Rate limit session creation to prevent abuse.

Failure handling checklist

FailureHandling
Connection drops mid-partRetry that part with backoff
Client closes the appSession persists; resume later by listing stored parts
Corrupted partChecksum mismatch, re-upload that part
Duplicate completion requestIdempotent: completing twice returns the same result
Abandoned uploadLifecycle rule cleans up the leftovers
Processing failsRetry from the event queue, mark the file as failed, tell the user

Real-world reading

Check your understanding

Question 1 of 3

0 correct so far

Why is it better for the client to upload straight to object storage using a pre-signed URL than to send the file through your application server?

Go deeper

© 2026 forcsguy.com. Original lesson text and diagrams. Books and sites linked above belong to their authors.