Walkthrough: Design a File Storage API

Topics Covered

Clarify and Model the File Storage Domain

Step one: clarify the consumers

Requirements that drive the design

Step two: model the resources

Files and folders: one resource or two?

Identifiers, not paths

What the interviewer is checking

Use cases to test the model against

Consistency expectations

A note on scale of individual folders

Design an API for a file storage service, in the spirit of a cloud drive or a document vault, is a favourite API design prompt because it combines things that are easy to get wrong. Files can be bigger than any request should be. Networks drop in the middle of uploads. Permissions are inherited through folders and shared with outsiders. Clients want to list millions of files and to sync only what changed. A strong answer walks the six step framework from lesson one and spends its depth on uploads, permissions and listing.

This lesson works the design end to end. Section one covers clarifying and modelling. Section two covers the style and the basic upload paths, including presigned URLs. Section three is the deep dive on multipart and resumable uploads. Section four covers downloads, metadata, sharing and permissions. Section five covers listing, sync, quotas, evolution and the wrap up.

Step one: clarify the consumers

Ask who calls the API. A typical answer has four consumers: first party web and mobile apps, desktop sync clients that mirror folders on disk, third party applications integrating through OAuth, and administrators managing an organisation's storage. Each pushes the design in a different direction. Mobile apps care about resumable uploads over flaky networks. Sync clients care about an efficient change feed. Third party apps care about scoped permissions. Administrators care about quotas, audit and retention.

Then ask about the files. What sizes? Most files in a drive are small documents and images, but a long tail of videos and backups reaches many gigabytes. Set limits explicitly: perhaps a maximum file size of 5 terabytes for the largest plans, with the common case under 10 megabytes. Ask whether files are versioned, whether they live in folders, whether they can be shared with people outside the organisation, and whether content needs to be previewed or searched. A good scope for a forty five minute round is: files and folders, versioning, uploads of any size with resume, downloads, sharing with users and links, listing and sync. Out of scope but named: full text search, real time co editing, and previews.

Requirements that drive the design

Say the non functional requirements, because each will justify a later choice. Durability: once an upload is acknowledged, the file must not be lost. Large files must not tie up API servers, so bytes should flow directly to object storage where possible. Uploads must survive network interruptions without restarting. Reads are far more frequent than writes, and downloads are bandwidth heavy, so they should be served from storage or a CDN rather than proxied. Permission checks must be correct and fast, including inherited folder permissions. Listing must work for folders with hundreds of thousands of entries.

A quick estimate helps. Suppose fifty million users, each with a few thousand files on average. That is on the order of a hundred billion file records. Uploads might average a few hundred per second overall with large peaks, and downloads several times more. The metadata store is large but each record is small; the bytes live in object storage. That division between a metadata service and a blob store is the most important architectural fact in the design, and the API should reflect it.

Small files can go through the API; large files should go straight to object storage.

Step two: model the resources

The resources are files, folders, versions, upload sessions, permissions and share links, plus changes for sync.

A file is the logical object a user sees: a name, a parent folder, a size, a content type, a checksum, a current version, an owner and timestamps. A folder is a container with a name and a parent, forming a tree under each user's or organisation's root. A version is an immutable snapshot of a file's content, created each time content is uploaded. An upload session represents an upload in progress and is the key to large and resumable uploads. A permission grants a principal, a user, group or domain, a role on a file or folder. A share link is a token that grants a role to anyone holding it, with optional expiry and password. A change records that something in a user's view of the tree changed, so sync clients can catch up.

Files and folders: one resource or two?

Some designs model folders as files with a special type, which simplifies moving and listing because everything is an item with a parent. Others keep them separate, which makes the schemas cleaner and the permissions logic more explicit. Either is defensible. A common compromise is a single items collection with a type field of file or folder, plus type specific fields, exposed through both /v1/items and convenient aliases. In this lesson we use separate files and folders resources for clarity, with a shared parent_id field and a combined children listing on each folder.

Identifiers, not paths

Identify files by stable opaque ids, such as file_88Q2, not by path. Paths change when anything above them is renamed or moved, and a rename of a top level folder would otherwise change the URL of every file inside it. Paths are still useful to display and for lookups, so offer a resolution endpoint, GET /v1/items:resolve?path=/Finance/Q4/report.pdf, that returns the item. Names inside a folder should be unique per type, or the API should define a conflict policy, because two files called report.pdf in one folder confuse both humans and sync clients.

json
1{
2  "id": "file_88Q2",
3  "object": "file",
4  "name": "report.pdf",
5  "parent_id": "fold_Q4",
6  "size": 2483112,
7  "content_type": "application/pdf",
8  "sha256": "9f2c1e...a7",
9  "current_version": "ver_3",
10  "owner": "user_ana",
11  "created_at": "2026-11-02T08:00:00Z",
12  "modified_at": "2026-11-28T16:20:00Z",
13  "etag": "\"f88q2-v7\""
14}

The etag reflects the metadata version and is used for optimistic concurrency on updates, as lesson five described. The sha256 lets clients verify downloads and skip uploading content the server already has.

What the interviewer is checking

In this opening the interviewer is checking that you separate metadata from bytes, identify files by stable ids rather than paths, name the upload session as a resource before you need it, and set explicit size limits. Candidates who start with POST /files carrying a multipart form body, and never return to large files, tend to struggle when the interviewer asks about a 20 gigabyte video on a train.

Use cases to test the model against

Before moving to the style, run the agreed use cases through the model out loud. A user uploads a photo from a phone: create a file in a folder, through a simple upload. A user uploads a 6 gigabyte video on hotel Wi Fi that drops twice: an upload session with parts, resumed from the parts list. A user edits a document and saves: a new version on the same file. A user shares a folder with a colleague: a permission on the folder, inherited by its contents. A user sends a link to an external auditor that should stop working at the end of the month: a share link with expiry. A laptop comes back online after a week: read the changes feed from its saved cursor. An administrator wants to know which files left the organisation: the audit trail of share link creations and accesses.

If each maps to a resource you already named, the model is complete enough. If one does not, such as a request for shared team drives owned by the organisation rather than a person, either add a resource, here a drive with its own root folder and membership, or explicitly move it out of scope. Shared drives are worth a sentence because ownership affects what happens when an employee leaves: files in a personal drive may be deleted with the account, while files in an organisation drive survive.

Consistency expectations

State what consistency each operation needs, because it decides where you can use caches and replicas. Metadata writes such as rename, move and permission changes should be strongly consistent for the caller: after a successful rename, the same user listing the folder sees the new name. Permission revocation must take effect quickly for everyone, ideally within seconds, because a revoked user still reading confidential files is a security incident. Search and recursive views can be eventually consistent, with a documented lag. Content reads after an upload commit should return the new version, which the atomic version pointer makes straightforward.

A note on scale of individual folders

Interviewers sometimes ask about one pathological folder, such as a camera upload folder with four hundred thousand photos. Name it early: listing and naming conflict checks must be indexed per parent, folder counts must be maintained counters rather than computed on demand, and moves of huge folders must not rewrite every descendant record. That last point influences the model. If every item stores its full path, moving a top level folder means rewriting millions of rows. If items store only their parent id, the move is one update, and path based lookups walk the tree or use a separately maintained ancestor index updated asynchronously.

Metadata and bytes are different systems

The single most important fact in a file storage design is that file metadata lives in a database and file bytes live in object storage. Let the API mirror that split: logic and permissions on your servers, bulk bytes flowing directly to storage.