“Design a file-storage service with uploads, downloads, and sharing.”
Assume authenticated users, files up to an illustrative 5 GB, resumable uploads, and versioned overwrites. We need metadata, blob storage, access control, and cleanup. Real-time collaborative editing and full desktop synchronization are separate problems.
01. Separate metadata from bytes
Store file identity, owner, folder, permissions, version, size, checksum, and state in a metadata service. Store immutable blob versions in object storage. A file's display name is not its storage key or authorization identity.
Define an upload lifecycle: initiated, uploading, verifying, available, failed, or expired. A partially uploaded object must not appear as a completed downloadable file.
Propose APIs to initiate an upload, obtain scoped upload authorization, complete it, list metadata, and request a download. Enforce user storage quotas at initiation and reconcile actual committed bytes at completion.
02. Keep large bytes off the application path
Issue short-lived upload authorization for the exact object key and operation. A presigned URL acts as a bearer capability, so avoid logging or sharing it casually. Choose a mechanism that can enforce the required size and content constraints; not every upload method supports identical restrictions.
S3's presigned upload documentation describes one implementation. A comparable storage service can be substituted without changing the basic separation.
03. Make large uploads resumable
Multipart upload divides a large file into independently retriable parts. Track upload ID, part numbers, completion state, and checksums. A client can retry a failed part instead of retransmitting the entire file.
For a 1 GiB file split into 16 MiB parts, there are 64 parts. If one part fails, retrying 16 MiB is far cheaper than starting over. Parallelism improves throughput only until network, client, or service limits dominate.
On completion, verify the expected parts, size, and supported checksums before exposing the file. Do not assume every object-store ETag is a plain MD5 of the complete file. The multipart upload guide explains the completion lifecycle.
04. Reconcile the metadata–object boundary
Object completion and a metadata transaction may not share one atomic commit. Use a durable state machine and a reconciler. If the blob is complete but metadata publication fails, retry publication idempotently. If metadata points to a missing blob, keep the file unavailable and investigate.
Version overwrites with an expected metadata version or ETag-style precondition. Two clients editing the same file should receive a conflict or explicit version history rather than silently losing one update.
Delete through a tombstone or retention-aware workflow. A background garbage collector removes orphaned and abandoned uploads after a safe interval, respecting active uploads and retained versions.
06. Defend the trade-offs
“Can we deduplicate identical files?”
Content hashes can help within a defined trust boundary, but global deduplication can reveal whether another user has a file and complicate deletion accounting. Start with simple ownership and storage semantics before optimizing.
“Uploads succeed, but users cannot find the file.”
Inspect the finalization state and metadata publication, not only the storage response. Monitor initiated-to-available delay and reconciliation backlog.
Proxying all large files unnecessarily, publishing partial uploads, treating ETags as universal checksums, or promising immediate revocation with long-lived bearer URLs.
Sources & further reading
File limits, part sizes, and service choices here are illustrative.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.