Skip to solution
hardSystem Design

How would you design a file storage service like Dropbox?

874 views
01

Understand the problem

Outline file storage.

file-storage
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Step 1: Outline use cases and constraints

Gather requirements and scope the problem. Ask questions to clarify use cases and constraints. Discuss assumptions.

Use cases

We'll scope the problem to handle only the following use cases

  • User performs core action described in How would you design a fil

Solution ready — 2 min read

Classified // press E to declassify

04

Read the code

Content-hash chunk dedup
Run Playground
import hashlib

store = {}    # content-addressed blocks: hash -> bytes (S3 in production)

def put_file(data, chunk_size=4):
    manifest = []
    for i in range(0, len(data), chunk_size):
        c = data[i:i + chunk_size]
        h = hashlib.sha256(c).hexdigest()[:8]
        if h not in store:                 # only upload NEW blocks (dedupe)
            store[h] = c
            print("upload", h, repr(c))
        else:
            print("skip (already stored)", h)
        manifest.append(h)
    return manifest                        # file = ordered list of chunk hashes

v1 = put_file(b"hello world data")
print("--- edit the end, re-sync ---")
v2 = put_file(b"hello world DATA")          # leading chunks unchanged -> reused
print("v1:", v1)
print("v2:", v2)
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 53 of 99 decoded in the System Design track. One more won't hurt.

Back to track