Resumable Upload Pattern
What you'll learn: How to build upload systems that remember progress and restart from where they left off when connections fail or users cancel.
Why Resumable Uploads Matter
Large file uploads can take minutes or hours. If the connection drops at 90%, starting over is frustrating and wasteful. The resumable upload pattern saves your progress and continues from the last successfully uploaded chunk—like bookmarking your place in a book before closing it.
The Core Pattern
You've already learned chunked uploads (splitting files into pieces). Resumable uploads add persistence and recovery:
- Track chunk completion – Store which chunks succeeded (in memory, localStorage, or server-side)
- Query upload state – Before resuming, ask the server: "Which chunks do you have?"
- Skip completed chunks – Only upload what's missing
- Handle interruptions gracefully – Save state when uploads pause or fail
Think of it like a jigsaw puzzle where you mark each placed piece. If interrupted, you don't redo finished sections—you pick up exactly where you stopped.
Implementation Strategy
When starting an upload, generate a unique upload ID (tied to file name, size, and modification date). Store this with chunk status locally. On resume:
- Send the upload ID to your server
- Server responds with which chunks it has
- Client uploads only missing chunks using the techniques from lesson 2717
Use the same XHR or Fetch progress tracking you learned earlier, but wrap it in state management that persists between sessions.
When Connection Fails
Catch network errors, save the current chunk index, and offer a "Resume" button. On click, restart the upload loop but skip chunks already marked complete. The user experience transforms from "try again from scratch" to "pick up seamlessly."
Key Takeaway: Resumable uploads combine chunked transfer with persistent state tracking, letting users continue large uploads after interruptions by skipping already-completed chunks.