LESSON 03 · Upload path

Resume and verify uploads

Use a scoped upload session, chunks, checksums, and explicit finalization.

SYSTEM VIEW

The file path

Diagram view
Chunks acked—
Resent—
New revisions—

Follow a 4 GB video through an upload that drops after chunk 480 and still lands as one revision.

  1. The Phone asks the File API for an upload session for its 4 GB video, naming base revision 2, the revision its edit started from. The File API checks identity, write permission and quota, then issues an expiring session that covers only this upload.

    Video
    4 GB
    Base
    rev 2
    Checks
    identity, write, quota

    What changed

    • Expiring upload session
    • Identity, write and quota checked
  2. The Phone sends the video straight to Object storage in numbered chunks of 8 MB, 500 in all. Object storage acknowledges each chunk and records the accepted ranges under the session. 480 chunks are acknowledged so far.

    File
    4 GB
    Chunk
    8 MB
    Chunks
    500

    What changed

    • 480 of 500 chunks acknowledged
    • Accepted ranges recorded
  3. The connection drops while chunk 481 is in flight. Object storage keeps the 480 acknowledged chunks under the session, so none of them has to travel again. Without a resumable session, the Phone would send all 4 GB again.

    Acknowledged
    480 chunks
    Missing
    20 chunks

    What changed

    • Chunk 481 lost in flight
    • 480 chunks kept
  4. The Phone reconnects to the same session and asks which ranges arrived. Object storage answers chunks 1–480, so the Phone resends only chunks 481–500: 20 chunks, 160 MB, not 4 GB. The bytes are durable now, but no revision exists yet.

    Resent
    20 chunks, 160 MB
    Instead of
    4 GB

    What changed

    • Chunks 481–500
    • 160 MB resent, not 4 GB
    • Durable, not yet a revision
  5. The Phone asks the File API to finalize. The File API checks the assembled size and checksum in Object storage, inspects the content per policy, then records revision 3 and its 500 blocks, in order, in Metadata DB. Only now is there a new revision.

    Verified
    size, checksum, policy
    Published
    rev 3

    What changed

    • Size and checksum verified
    • Rev 3 in Metadata DB
  6. The File API’s reply is lost, so the Phone times out and sends finalize again. Finalization is idempotent: a repeat has the same effect as the first call, so the File API returns revision 3 again and Metadata DB still holds one new revision.

    Finalize calls
    2
    New revisions
    1

    What changed

    • Reply lost, Phone times out
    • Same result: rev 3
    • Still one new revision
  7. Chunk size is a trade-off. In 2 MB chunks, the same 4 GB file takes 2,000 requests instead of 500, with more ranges for the session to track, though a drop costs less to resend. Small files may not need a session at all.

    8 MB chunks
    500 requests
    2 MB chunks
    2,000 requests

    What changed

    • 2,000 requests in 2 MB chunks
    • Less to resend after a drop
    • Small files may skip the session
  8. If the Phone gives up on an upload, its session’s accepted chunks stay in Object storage, consuming space until a cleanup rule removes them. S3 offers a lifecycle rule for incomplete multipart uploads.

    Abandoned
    chunks still stored
    Cleanup
    lifecycle rule

    What changed

    • Abandoned chunks hold storage
    • Lifecycle rule removes them

Space plays · ← → step · Home resets

THE IDEA

How it works

The client requests a session for a file and expected base revision, meaning the revision its edit started from. The API checks identity, write permission, and quota, then issues an expiring session or scoped storage permission. Numbered chunks let the client ask which byte ranges were accepted and resume only missing ranges after an interruption.

Take a 4 GB file in 8 MB chunks, which is 500 chunks. If the connection drops after 480 are acknowledged, the client asks for accepted ranges and resends 20 chunks: 160 MB, not 4 GB. S3 multipart upload and Google Cloud Storage resumable uploads work along these lines. Smaller chunks lose less on failure but cost more requests and session state, and small files may not need a session at all. Abandoned sessions also keep consuming storage until a cleanup rule removes them; S3 offers a lifecycle rule for incomplete multipart uploads.

At finalization, verify assembled size and checksum, inspect content according to policy, and record the ordered blocks. A content hash can help detect duplicates within an approved scope, but hash equality does not grant access. Compression helps text more than already-compressed media such as video. Encrypt stored content and manage keys separately. Make finalization idempotent, meaning a repeat has the same effect as the first call, so a timed-out retry does not create two revisions.

DECISION POINT

A 4 GB upload loses its connection near completion. How should it recover?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Resumable chunks save bandwidth; checksums detect corruption.
  • Durable receipt and published revision are separate states.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 2
ApplyQUESTION 01

A 2 GB upload in 10 MB chunks drops after 150 chunks are acknowledged. How much must the client still send?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 2 checkpoints answered correctly to complete this lesson.