Object storage concepts
Store a file as an object
Object storage keeps a payload (the bytes of a picture, report or backup) together with a name and metadata. An application normally retrieves an object by sending an API request to a storage service. The service manages its underlying disks. For our fictional bookstore, store book cover images in object storage and keep searchable book titles and object identifiers in a database. The database is the catalog; object storage holds the image bytes. A file share is a better candidate when an application requires shared filesystem operations such as in-place updates or file locking. A virtual disk is a better fit for a guest OS boot device.
Compare the three provider vocabularies
Amazon S3 stores objects in buckets, addressed by object keys. Azure Blob Storage stores blobs in containers within a storage account. Google Cloud Storage stores objects in buckets, identified by object names. These are analogous roles, not interchangeable APIs. An account or project also establishes resource ownership and billing. Choose location, redundancy, namespace type, quotas and identity policy for the selected service; do not assume the same isolation, replication or naming rules.
Design keys and metadata for a catalog
Suppose our private catalog contains covers/b001/front.jpg (800 KB), covers/b001/thumb.jpg (80 KB) and covers/b002/front.jpg (600 KB). A flat-namespace prefix is a string at the beginning of a name, not necessarily a real directory. Listing the prefix covers/b001/ selects two objects totaling 880 KB; listing covers/ selects all three. Some services offer hierarchical namespace features with distinct directory semantics and restrictions. Use stable synthetic book IDs rather than personal names or mutable titles. Set the content type to image/jpeg and record a catalog ID in application metadata if needed. Metadata is not a relational query engine; keep full-text search and business relationships in a separate catalog. Do not put credentials in keys or metadata.
Read, write and list objects
A small upload normally sends the object payload, name and permitted metadata. A read retrieves bytes or metadata; a listing returns object identifiers matching the requested scope and may span several pages. An overwrite commonly creates a replacement object rather than editing arbitrary bytes through a file handle. Some Azure blob types support specialized block, append or page operations; these are service-specific, not universal file semantics. A single object write can be atomic without providing a transaction spanning multiple objects. If two editors update a cover, use conditional requests with the applicable ETag or generation token to reject an outdated write instead of silently losing the first update.
Understand consistency without overpromising
For ordinary direct object operations, S3 and Google Cloud Storage document strong consistency for successful writes and relevant listings; Azure Blob Storage supports optimistic concurrency using ETags. An application should not add an arbitrary sleep after every successful write. However, a CDN or browser cache can return an earlier representation, replicated destinations can lag, and permission or bucket-configuration changes can propagate differently. Use the actual endpoint, version, response code and cache policy when investigating a stale image. Do not treat strong consistency as a guarantee of zero downtime or as a multi-object transaction.
Transfer large files safely
A large file can be divided into pieces rather than resending everything after a dropped connection. S3 multipart upload uses an initiation step, numbered parts and completion; Azure block blobs can stage blocks and commit a block list; Google Cloud Storage supports resumable uploads using a session URI. These mechanisms have different APIs, limits and recovery semantics. In a toy 25 MB file divided into 10 MB chunks, the three chunks are 10, 10 and 5 MB. If the second piece fails, retry according to the provider protocol and verify the completed object size and supported checksum. Do not assume every ETag is a checksum. Treat upload session URIs as credentials. Review incomplete upload cleanup and billing before using real storage.
Try it offline
Use the synthetic object inventory in the chapter fixture. Select the objects whose names begin with covers/b001/, then calculate their total bytes. Explain why covers/b001 without the final slash could also match covers/b0010/front.jpg. Design a conditional update for an editor holding an old revision. No provider account, network or SDK is necessary. Next, learn how to limit access and retain recoverable versions.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Object storage concepts — knowledge check
Choose the best answer for each offline scenario.
Which resource should hold image bytes when the database contains searchable book titles?
Which prefix selects only book b001 objects from b001 and b0010?
Two editors have read revision A. One saves revision B. What should the other use to prevent an accidental overwrite?
A CDN serves an old cover after a successful origin update. What should you inspect?
A 25 MB file is divided into 10 MB chunks. What are the sizes?