Skip to content

    System Design

    Object and Blob Storage: Keys, Multipart Uploads, Presigned URLs

    Learn how object storage differs from files and databases: flat keys, whole-object writes, versioning, multipart uploads, lifecycle rules and presigned URLs.

    By Published 14 min read

    Share

    Standard lessonintermediateSpring Boot labBackend System Design

    Before this: CDN and Object Storage

    What you'll learn: By the end of this lesson you will be able to explain what an object store is and is not, describe why keys only look like folders, say what versioning and delete markers do, run a multipart upload in your head (including what an abandoned one costs), reason about presigned URLs as bearer tokens, and design ShopStream's photo and invoice storage with the failure cases in mind.

    A cloakroom does not let you alter a coat while it hangs there. You hand it over, get a numbered ticket, and later hand the ticket back to receive the whole coat. If the lining needs mending you take the coat out and hand in a new one under the same number. The cloakroom is enormous and cheap, and it cannot answer "which coats are red?".

    An object store works like that cloakroom. This lesson goes deeper than the CDN and object storage lesson, which introduced buckets, presigned URLs and multipart uploads inside a photo flow. Here the subject is the storage itself: what a write means, what a key is, what versioning keeps, how multipart really works and what unfinished uploads cost. How a CDN caches the result is in CDN and edge networking.

    Verified on 2026-12-01 against the Amazon S3 User Guide and the Google Cloud Storage documentation. The lab on this page is an in-memory model of the ideas, not S3, and no provider's behaviour is claimed from it.

    The core idea

    An object store keeps whole objects, each under a key in a flat namespace, and gives you a small set of whole-object operations over HTTP. Anything else (folders, queries, partial edits, per-user access) is built on top. Four consequences run through the lesson: a write replaces an object, a "folder" is a listing trick, a large upload is assembled from parts, and access is by signature rather than by login.

    Three illustrations run through it, each labelled:

    • Minimal example: the lab's bucket model, with keys, versions, parts and signatures.
    • Realistic example: ShopStream store tablets uploading product photos and invoice PDFs.
    • Failure example: unfinished multipart uploads quietly filling storage.

    What an object store is

    The S3 User Guide describes an object as "a file and any metadata that describes the file" and a bucket as "a container for objects". An object's key is "the unique identifier for the object within a bucket", so S3 can be thought of as "a basic data map between 'bucket + key + version' and the object itself". Buckets are private by default. Google Cloud Storage's documentation says its objects are immutable: "an uploaded object cannot change throughout its storage lifetime", and you "cannot make incremental changes to objects, such as append operations or truncate operations", though you can replace an object and "doing so happens atomically".

    That is a different tool from a disk or a database. Compare the storage engines lesson and the SQL vs NoSQL framework: an object store has no query by content, no transaction across keys and no in-place update, and in return it scales to a very large number of large objects.

    Where object storage sits in a photo and invoice flowStore tablet to App server (ask for a slot); App server to Database (pending row); Store tablet to Bucket (bytes, signed url); Bucket to CDN (origin)Store tabletStore tabletApp server: signs, recordsApp serversigns, recordsDatabase: metadata, statusDatabasemetadata, statusBucket: bytes by keyBucketbytes by keyCDN: serves readersCDNserves readersask for a slotpending rowbytes, signed urlorigin

    Figure 1. The bytes skip the application. How to read this: the app server decides who may upload and keeps the metadata. The bytes travel straight from the client to the bucket, and readers get them through the CDN. The database row and the object are linked only by the key.

    Writes, consistency and what "atomic" means

    The S3 User Guide says S3 provides "strong read-after-write consistency for PUT and DELETE requests of objects in your Amazon S3 bucket in all AWS Regions", for new objects, overwrites and deletes. "Updates to a single key are atomic": a concurrent reader gets "either the old data or the new data, but never partial or corrupt data". Two limits matter as much. S3 "does not support object locking for concurrent writers": if two PUTs hit one key at once, "the request with the latest timestamp wins". And updates are key-based: "There is no way to make atomic updates across keys." Bucket configuration changes are different again: the guide says they have an eventual consistency model, and recommends waiting 15 minutes after first enabling versioning before issuing writes.

    So the unit of atomicity is one key. A design that needs "object and database row change together" must build that itself, as the photo status contract does in the CDN and object storage lesson. Compare idempotency keys for making the retried step safe.

    Keys, prefixes and the folder illusion

    S3 says prefixes "are not directories", though "you can think of prefixes as a way to organize your data in a similar way to directories". A listing with a prefix returns only keys that begin with it, and a delimiter makes the listing "roll up all the keys that share a common prefix into a single summary list result", returned as common prefixes. The maximum key length is 1,024 bytes. Google's documentation says that in a flat namespace "there are no directories or folders that objects exist within" and that "some tools implement the appearance of folders".

    That has practical weight: a "folder" that exists only as a shared prefix has no object of its own, so any work on it is work on every key under the prefix. Key design is your schema: put the tenant or listing id early, keep keys unique and immutable, and never put user-supplied text in a key without validating it.

    Versioning and delete markers

    With versioning, S3 can "keep multiple variants of an object in the same bucket". An object that existed before versioning was enabled has the version ID null. In a versioning-enabled bucket a plain delete does not remove data: "the delete marker makes Amazon S3 behave as if the object is deleted". A get without a version ID then returns 404 with the header x-amz-delete-marker: true, a normal list does not return the key, and the older versions remain. A delete marker "doesn't have data associated with it" but accrues a minimal storage charge; the older versions keep costing storage until something removes them.

    stateDiagram-v2 accTitle: Versions of one key with a delete marker accDescr: A key starts with no object. A first put creates version one. A second put creates version two, which becomes current. A plain delete adds a delete marker that becomes current, so a normal get returns not found while versions one and two remain readable by version id. [*] --> V1: put V1 --> V2: put again V2 --> Marker: plain delete Marker: Delete marker (current) V1: Version 1 (kept) V2: Version 2 (kept)

    Figure 2. Delete in a versioned bucket. How to read this: nothing is erased. The marker is simply the newest version, and a read of the key without a version id treats the key as absent.

    Versioning protects against an accidental overwrite or delete. It is not a backup against losing the bucket or the account, and it multiplies storage for frequently overwritten keys.

    Multipart upload

    A large object is uploaded as parts. The guide describes a three-step process: initiate, upload the parts, complete. Parts can be uploaded "independently, and in any order", a failed part can be retransmitted "without affecting other parts", and a part number can be anything from 1 to 10,000 and need not be consecutive. Uploading a part with a number already used overwrites the earlier part. On completion, S3 "creates an object by concatenating the parts in ascending order based on the part number", and the complete request lists part numbers with their ETags. The ETag of the result "is not necessarily an MD5 hash of the object data".

    The limits table says, at the time of writing: maximum object size 48.8 TiB, up to 10,000 parts, part size 5 MiB to 5 GiB, and no minimum on the last part. The guide suggests considering multipart "when your object size reaches 100 MB".

    sequenceDiagram accTitle: A multipart upload from initiation to completion accDescr: The client initiates an upload and receives an upload id. It sends parts in any order, in parallel, retrying one failed part without restarting. It then sends a complete request listing part numbers and etags. The store assembles the parts in part-number order and the object becomes readable. participant C as Client participant S as Object store C->>S: initiate upload for key S-->>C: upload id par parts in parallel C->>S: part 3 C->>S: part 1 C->>S: part 2 (fails) end C->>S: part 2 again S-->>C: part etags C->>S: complete: parts 1, 2, 3 with etags S-->>C: object created

    Figure 3. Parts then completion. How to read this: nothing is readable until the final call. A failed part is sent again on its own, which is why multipart helps on unreliable networks.

    The cost of an abandoned upload

    The S3 guide says that after you initiate an upload and send parts "you must either complete or stop the multipart upload to stop incurring charges for storage of the uploaded parts", and that an initiated upload has no expiry. It recommends a lifecycle rule using the AbortIncompleteMultipartUpload action: S3 stops uploads "that aren't completed within a specified number of days after being initiated" and deletes their parts. The rule deletes no objects and does not affect completed uploads.

    Presigned URLs

    A presigned URL grants "time-limited access to objects" without changing the bucket policy. You give your credentials, a bucket, a key, an HTTP method and an expiry, and the URL carries a signature. The credentials used are those of the principal who generated it, so the URL can do no more than that principal could. The guide calls presigned URLs "bearer tokens that grant access to those who possess them": it can be used "multiple times, up to the expiration date and time", and an upload URL replaces an existing object with the same key. Expiry is checked at the time of the request: a download that began before the expiry continues. Maximum validity depends on the credentials: up to 7 days with IAM user credentials, shorter for temporary credentials, and the logs "identify the signer, not who later uses the URL".

    sequenceDiagram accTitle: Presigned upload and a rejected reuse accDescr: The client asks the application for permission to upload. The application checks the user, signs the method, key and expiry, and returns a URL. The client uploads directly to the bucket, which checks the signature. A copy of the same url used for another key, or after expiry, is rejected. participant C as Client participant A as App server participant B as Bucket C->>A: may I upload photo for product 17? A->>A: check the user, sign method + key + expiry A-->>C: signed URL C->>B: PUT bytes to the signed URL B->>B: verify signature and expiry B-->>C: 200 ok C->>B: same URL, other key or after expiry B-->>C: 403

    Figure 4. The bucket checks a signature, not a user. How to read this: the application's authorization check happens before signing. After that, anyone holding the URL can use it until it expires.

    Build it: a bucket model in Java and Spring

    The lab is examples/spring-labs/labs/object-blob-storage. What it is: an in-memory Java model of a bucket (Bucket), a signature checker (Presigner) and a Spring MVC controller that MockMvc calls. What it is not: S3 or any real service. There is no durability, network or storage class. Etags are the first 12 hex characters of a SHA-256; the model's multipart etag is its own composite; the minimum part size is a constructor argument (10 bytes in the demo, where real services use mebibytes); the signature is an HMAC-SHA256 over a simple string, not any provider's format. Everything said above about real services comes from the documentation cited, not from this lab.

    Run it from examples/spring-labs:

    ./gradlew :labs:object-blob-storage:test

    The command runs 11 tests, including GoldenRunTest, which compares the report below with examples/spring-labs/golden/object-blob-storage.txt.

    Keys, listings and whole-object writes

    Expected output, captured from a real run (Java 25, Spring Boot 4.1.2, in-memory model, 2026-12-01):

    == 1. A flat key space and whole-object writes ==
    5 objects stored; the keys contain slashes but there are no folders
    list prefix "listings/" delimiter "/": keys [], common prefixes [listings/8841/, listings/9002/]
    list prefix "listings/8841/" delimiter "/": keys [listings/8841/tour.mp4], common prefixes [listings/8841/photos/]
    list prefix "listings/8841/" no delimiter: keys [listings/8841/photos/a.jpg, listings/8841/photos/b.jpg, listings/8841/tour.mp4], common prefixes []
    put the same key again: size 35 -> 56 bytes, etag 2a653575df1c -> cdf48a2c6a03
    There is no call that edits part of an object: a change is a new put of the whole object.

    The delimiter groups keys at one level; nothing named photos was ever stored. The second put changed the size and the etag: it is a new object under the old key.

    Delete with and without versioning

    Expected output, captured from a real run (the same run):

    == 2. Delete with and without versioning ==
    versioning off: after put, put, delete: get -> not found, history [], bytes held 0
    versioning on : after put, put, delete: get -> not found, history [v1 13 bytes, v2 18 bytes, v3 (delete marker)], bytes held 31
    get by version id v1 -> "invoice draft"
    With versioning off the delete is final. With it on, the delete adds a marker and every old version keeps costing storage.

    Both buckets answer "not found". Only the versioned one still holds 31 bytes and can read version v1.

    Multipart upload

    Expected output, captured from a real run (the same run):

    == 3. Multipart upload (model minimum part size 10 bytes; real services use mebibytes) ==
    parts sent in the order 3, 1, 2, then part 2 sent again (a retry): etag of the first try fc11d6f28e59, of the retry 9e5ced8b9064
    nothing is readable yet: get -> not found
    complete with parts 1, 2, 3 -> size 26 bytes, etag 8a3678b0fe9d-3, content "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    three 4-byte parts: rejected, part 1 is 4 bytes; every part except the last must be at least 10 bytes in this model
    parts listed as 2, 1: rejected, parts must be listed in ascending order
    part 1 listed with the etag of part 2: rejected, part 1 is missing or its etag does not match

    Parts sent in the order 3, 1, 2 assemble in part-number order. Re-sending part 2 replaced the first try. The model rejects a short non-final part, an unordered list and a wrong etag, mirroring the rules the documentation describes for real services.

    An abandoned upload and the lifecycle rule

    Expected output, captured from a real run (the same run):

    == 4. An abandoned upload and the lifecycle rule ==
    day 0: one object of 5 bytes and an unfinished upload with 2 parts: bytes held 25, incomplete uploads 1
    day 3: rule "abort incomplete uploads older than 7 days" aborts 0; bytes held 25, incomplete uploads 1
    day 8: rule "abort incomplete uploads older than 7 days" aborts 1; bytes held 5, incomplete uploads 0
    The parts were invisible to every get and list, yet they were stored, and counted, until the rule ran.

    Twenty of the 25 bytes held belong to an upload nobody can read. This is the shape of the surprise bill.

    Presigned URLs over HTTP

    ObjectController answers 403 unless the signature is valid for the request's own method and key.

    Expected output, captured from a real run (the same run):

    == 5. Presigned URLs (Spring MVC, MockMvc, HMAC model) ==
    t=0     server signs a PUT url for 600 seconds: /objects/listings/8841/photos/new.jpg?expires=600&sig=3467aac7caaa8557
    t=0     PUT with that url                    -> 200, etag 1b48e2128296
    t=0     GET with a GET url                   -> 200, etag 1b48e2128296
    t=0     PUT using the GET url's signature    -> 403 (BAD_SIGNATURE)
    t=0     PUT the signed url on another key    -> 403 (BAD_SIGNATURE)
    t=0     PUT with expires raised by 1000 s    -> 403 (BAD_SIGNATURE)
    t=601   PUT with the original url            -> 403 (EXPIRED)
    t=601   GET a missing key with a valid url   -> 404
    The bucket checked a signature, not a user: whoever holds a valid url can use it until it expires.

    The signature covers the method, the key and the expiry, so changing any of them fails. After expiry the same URL fails. Nothing in the check identifies a person.

    Trade-offs

    Choice Gain Cost Wrong when
    Object storage for bytes Cheap, huge, durable by redundancy Whole-object writes, no query, key-level atomicity You need in-place updates or joins
    Direct presigned uploads App servers never carry bytes Signed URLs are bearer tokens URLs leak or live too long
    Multipart upload Parallel, resumable parts, large objects Part bookkeeping; abandoned parts cost Objects are small
    Versioning on Recover from overwrite and delete Old versions cost storage Keys are overwritten constantly
    Lifecycle abort rule Bounds orphaned parts Must be set per bucket Long-running uploads exceed the limit
    Metadata in a database Searchable, transactional Two stores to keep in step One store is enough

    In practice: ShopStream store photos and invoice PDFs

    This is an educational scenario using ShopStream's shared illustrative numbers.

    This is a realistic scenario, not a case history.

    The situation

    This is the realistic example. ShopStream has 5,000 stores and 100,000 products per region (the shared figures, illustrative). Store staff photograph products on tablets, often on weak connections, and each order produces an invoice PDF. Today the app server receives the photo, writes it to a bucket and stores the key. Photos of 5 to 40 MB time out on slow links, and staff retry from the start. Finance also asks for a way to recover an invoice that was deleted by mistake.

    Starting architecture

    ShopStream photos and invoices, starting architectureStore tablets to App servers (whole file); App servers to Bucket (put); App servers to DatabaseStore tabletsStore tabletsApp servers: carry the bytesApp serverscarry the bytesBucket: photos, invoicesBucketphotos, invoicesDatabase: keys, statusDatabasekeys, statuswhole fileput

    Figure 5. Bytes through the app servers. How to read this: every byte of every photo passes through the app tier, and a failed upload restarts from zero.

    Options considered

    Option Gain Cost Wrong when
    A. Bigger timeouts and compress on the tablet Tiny change Bytes still use app capacity; restarts remain Files are large and links weak
    B. Presigned single PUT Bytes skip the app A failed upload still restarts Files exceed what one request survives
    C. Presigned multipart for large photos, single PUT for small ones, abort rule, versioning on the invoices bucket Resumable uploads, bounded orphans, recoverable deletes Client part logic; version cleanup to manage The team cannot own the client code

    The decision

    Option C. The app server authorizes the store and product, creates a pending photo row with a unique key, and returns signed URLs valid for minutes and scoped to that key and method. Tablets send parts of a size chosen from the provider's documented limits and re-send failed parts. A lifecycle rule aborts incomplete uploads after seven days (the number used in the S3 documentation's example; the business can choose another). The invoices bucket has versioning on, and a rule keeps old versions for a period finance sets.

    ShopStream photos and invoices, target architectureStore tablets to App servers (ask for url); App servers to Database; Store tablets to Photos bucket (signed parts); App servers to Invoices bucket (invoice pdf)Store tablets: send partsStore tabletssend partsApp servers: authorize, signApp serversauthorize, signDatabase: pending, readyDatabasepending, readyPhotos bucket: abort rulePhotos bucketabort ruleInvoices bucket: versioning onInvoicesbucketversioning onask for urlsigned partsinvoice pdf

    Rollout and verification

    Start with new uploads for a small share of stores. Verify that a signature for one key fails on another and that an expired URL fails. Verify that a deliberately interrupted upload leaves no orphan after the abort rule runs, using the provider's listing of in-progress uploads, and that a deleted invoice is still readable by its version. Watch upload success rate, part retries and total bytes stored against bytes in visible objects.

    The 2 a.m. failure

    The page reads: "bucket bytes growing 3x faster than visible photos". Tablets on poor links are starting uploads and abandoning them; the abort rule was configured on the staging bucket but never on production.

    flowchart TD accTitle: Orphaned parts from abandoned uploads accDescr: A tablet starts a multipart upload and sends some parts. The connection drops and the tablet never completes or aborts. The parts stay stored and billed. With no abort rule they accumulate, so stored bytes grow faster than the count of visible objects. A["Tablet starts multipart upload"] --> B["Sends some parts"] B --> C["Connection drops, no complete or abort"] C --> D["Parts stay stored and billed"] D --> E{"Abort rule on this bucket?"} E -->|no| F["Orphans accumulate"] E -->|yes| G["Parts removed after N days"]

    First checks: list in-progress multipart uploads for the bucket (the guide describes a list operation for them), compare stored bytes with the sum of visible object sizes, and confirm whether the lifecycle rule exists on this bucket. Mitigation: add the abort rule, and abort the old uploads. Follow-up: manage bucket configuration as code, with a test that every bucket that accepts multipart uploads has the rule.

    Architect's notes

    • Treat the key as a schema: tenant or owner first, immutable and unique, validated.
    • Keep metadata in a database and let the key be the link; decide who owns the pending-to-ready transition.
    • Sign narrowly and briefly: one key, one method, minutes, after an authorization check.
    • Count orphaned bytes as a metric next to visible bytes.
    • Do not treat versioning as backup. Decide the retention of old versions with the owner of the data.
    • Read the provider's limits page at design time; they change, and the numbers here are those at the time of writing.

    Common mistakes

    • Expecting a partial update or append on an object.
    • Assuming a delimiter creates folders and designing permissions around them.
    • Leaving incomplete multipart uploads with no abort rule.
    • Long-lived, broad presigned URLs, treated as if they identified a user.
    • Putting searchable metadata in the object store instead of a database.
    • Assuming two keys can be changed together.

    Key takeaways

    • An object store writes and reads whole objects by key; the namespace is flat.
    • Strong read-after-write consistency applies per key; there is no atomic update across keys.
    • Folders are a listing feature: prefixes and delimiters, not directories.
    • With versioning, a delete adds a marker and old versions stay (and cost).
    • Multipart upload assembles parts in part-number order; unfinished uploads cost money until aborted, so set an abort rule.
    • A presigned URL is a bearer token: sign narrowly and briefly.
    • Keep searchable metadata in a database and link it by key.

    Practice exercises

    Exercise 1 (30 min). Run the lab and add a fourth part number 7 to the multipart scenario (skipping 4 to 6). Does completion still work in the model? Which line of the S3 documentation says it should?

    Exercise 2 (1 hour). Design the key scheme for ShopStream product photos with versions (original, 400 px, 800 px). Decide what is immutable and what a "replace the photo" action does to the keys.

    Exercise 3 (2 hours). Extend the lab so a presigned URL also signs a maximum content length and the controller rejects a larger body. Write the test first.

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments