LESSON 03 · Media path

Keep media off the post row

Store post metadata and media bytes in systems suited to their different access patterns.

SYSTEM VIEW

The feed path

Diagram view
Post row—
Page query—
Link valid—

Watch a 5 MB video take its own path to storage and a CDN while the post row keeps only its key.

  1. The Author asks the Post API where to upload a 5 MB video. The API answers with a presigned URL: permission to write one object, uploads/v91, for 15 minutes. The bytes themselves take another path.

    Object
    uploads/v91
    Valid for
    15 minutes

    What changed

    • Presigned URL for uploads/v91
    • Valid for 15 minutes
  2. The Author sends the 5 MB video straight to Object storage, a service such as S3 that stores large files by key, with a PUT to uploads/v91. The bytes never pass through the Post API.

    Key
    uploads/v91
    Size
    5 MB

    What changed

    • 5 MB original at uploads/v91
    • No bytes through the Post API
  3. The Media processor reads uploads/v91, scans it, resizes it and transcodes it into 3 variants, such as 720p, which it writes back to Object storage. Normally a post references the video only once its variants are ready.

    Source
    uploads/v91
    Variants
    3, such as 720p

    What changed

    • Media processor
    • 3 variants of v91
    • Ready before any post
  4. The Author publishes post 4417, and the Post API commits 1 KB of metadata to the Post store: owner, text and the key v91. A page of 20 posts reads 20 KB; with the 5 MB video in every row, it would move 100 MB.

    Page of 20
    20 KB
    Video in rows
    100 MB

    What changed

    • Post 4417: 1 KB with key v91
    • No video bytes in the row
    • A page of 20: 20 KB
  5. A Reader opens the feed. The Feed service returns posts with media URLs, never the bytes, and the Reader fetches v91 in 720p from the CDN, a set of caches near readers. Object storage keeps the durable original and variants.

    Page
    posts + media URLs
    Bytes
    from the CDN

    What changed

    • Author, Post API, Media processor
    • Reader, Feed service, CDN
    • Page with media URLs
    • 720p bytes from the CDN
  6. For private media, the Feed service checks who may see v91, then signs a CDN URL for 5 minutes, as CloudFront signed URLs do. The CDN serves v91 only with a valid signature. Each page needs fresh links; a leaked one works until it expires.

    Signed for
    5 minutes
    Leaked link
    works until expiry

    What changed

    • Signed URL for 5 minutes
    • The CDN checks the signature
    • Fresh links on every page
  7. Pick a case. Publish fails: uploads/v92 has no post, so a lifecycle rule expires it after 1 day. Still processing: the Reader sees an explicit pending state. Post deleted: the CDN must refuse v91’s old link within the revocation window.

    Orphan upload
    expires after 1 day
    Slow processing
    shown as pending
    Deleted post
    revoked in a window

    What changed

    • Orphans expire after 1 day
    • Pending state while processing
    • Revocation window for deletes
    Case

Space plays · ← → step · Home resets

THE IDEA

How it works

The client uploads images or video to object storage, a service such as S3 that stores large files by key, through a controlled upload path such as a presigned URL valid for one object and a short time. Processing workers can scan, resize, or transcode (convert to other formats and bitrates) the files before a post references a ready media object. The post database retains metadata, ownership, and object keys; it does not carry large video bytes through every feed query. In an example page of 20 posts, 1 KB of metadata each comes to 20 KB; with a 5 MB video stored in each row, the same query would move 100 MB.

A CDN (content delivery network, a set of caches near readers) serves approved variants. The feed API returns media URLs or tokens alongside post metadata; the browser fetches the bytes separately. Private media requires an authorization-aware delivery strategy, such as short-lived signed access, rather than assuming a public CDN URL is safe. CloudFront signed URLs work this way. The cost is that each page needs freshly signed links, and a leaked link still works until it expires.

If upload succeeds but publishing fails, clean up the unreferenced object after a grace period; a temporary upload prefix with an S3 lifecycle expiry rule is one simple way. If processing is delayed, show an explicit pending state or postpone publication according to the product promise. Deleting a post must also make cached media inaccessible within the required revocation window.

DECISION POINT

A private video is deleted, but its old CDN URL still works. Which boundary failed?

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

Keep in mind

  • Object storage holds bytes; post storage holds ownership and references.
  • A CDN improves delivery, while privacy and cleanup still need explicit rules.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

Where do the large image and video bytes belong?

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

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.