How it works
Store file identity, owner, parent folder, name, current revision, status, size, and access rules in a metadata database. Immutable content blocks, the pieces a file is split into, live in object storage such as S3. A revision manifest lists ordered block keys and checksums so a download can rebuild that version. Stable file IDs let a rename preserve identity and history: renaming a 2 GB file updates one row and moves no bytes. Dropbox draws a similar line, keeping file blocks in its Magic Pocket store and metadata in separate databases.
Metadata and object storage cannot share a simple database transaction, so order the steps. Suppose revision 8 of a file has three blocks. The API inserts revision 8 as pending with its manifest. The client uploads the three objects. The API confirms each one exists with the right checksum, then in one database transaction sets the current revision to 8 and appends a change-log entry. If the API crashes before that commit, readers still see revision 7.
A transactional outbox can deliver notifications after commit: it is a table written in the same transaction, which a separate process reads and publishes from. The cost of two stores is cleanup. Abandoned uploads leave orphaned objects that no manifest references, so reconcile orphaned objects and pending records before deleting anything. A very small service can reasonably keep small files in the database and skip this split until size forces it.
The object arrived, but the API crashed before marking the revision ready. What should readers see?
Serve the prior ready revision or a clear pending state. Reconciliation can verify and publish the new object or later clean it up.
Use this as a guide for self review; written answers are not graded.Keep in mind
- Metadata describes and authorizes files; object storage holds bytes.
- Publish only after required content is verified.