Lesson 12 of 17
38. Design a Chat App (WhatsApp)

38.11 How does media work?

3 min read+10 XP

Photos and videos are too big for the chat path:

  1. The sender's app encrypts the file with a fresh random key.
  2. It uploads the encrypted blob to object storage with a presigned URL (Chapter 11).
  3. It sends a normal chat message containing the blob ID, the key and a thumbnail, itself end-to-end encrypted.
  4. Recipients download the blob (through a CDN, Chapter 26) and decrypt it with the key from the message.

The server never sees the image in the clear, and forwarding a photo to ten chats can reuse the same uploaded blob. Blobs expire after everyone has downloaded them (or after a set time).

Memory code: "Upload the locked box, send the key in the message."