The S3 API
Buckets, keys, prefixes, metadata, multipart uploads, range reads, and presigned URLs
The S3 API is a few dozen HTTP operations. A handful of them cover almost
everything applications do. labs/s3_basics.py exercises each against the
cluster.
docker compose -f compose_prod.yaml run --rm labs python s3_basics.py
buckets: ['app-data', 'backups', 'drill', 'finance', 'probe', 'versioned']
head: 38 bytes, application/json metadata {'source': 'lab'} etag "e9892c47a54242a11c1db5ef165f7a90"
top level: ['invoices/'] ['during-master-failover', 'logo.png', 'report.txt', 'two-masters-down']
prefix invoices/2026/10/: ['invoices/2026/10/inv-1.json', 'invoices/2026/10/inv-2.json']
multipart: 3 parts, 24 MiB in 0.15s, etag "2f0c15edcb02835be145a1377cdfaa5c-3", intact=True
range read: 1024 bytes, matches: True
presigned GET with no credentials: {"key": "logo.png"}Buckets and keys
A bucket is a namespace with its own settings (access, versioning, lifecycle). A key is any string up to 1,024 bytes. Inside a bucket, keys are just a flat, sorted list.
The ETag of a simple upload is the MD5 of the bytes, so clients can check integrity. Metadata is set at upload and can't be edited in place: to change it you copy the object onto itself with new metadata.
There are no folders
invoices/2026/10/inv-1.json is one key with slashes in it. Listing with a
delimiter groups keys by the next /, which is how every S3 browser
draws folders:
Listings return at most 1,000 keys per call; use a paginator. Design keys
so the listings you need are prefix listings: tenant/42/uploads/...
lets you list or delete one tenant's files; a random UUID as the whole key
doesn't.
Multipart uploads
Large objects are uploaded in parts (5 MiB minimum except the last, up to 10,000 parts), in parallel and retryable one at a time:
A multipart ETag is the MD5 of the parts' MD5s with -N appended, so it
can't be compared to md5sum of the file. Code that verifies uploads by
ETag breaks the first time a file crosses the SDK's multipart threshold
(8 MiB by default in boto3). Store your own checksum in metadata, as the
durability lab does.
An upload that's started and never completed or aborted leaves its parts stored and invisible to normal listings. Add a lifecycle rule to abort incomplete uploads after a few days.
Range reads
Range: bytes=0-1023 returns just those bytes. Video players, Parquet
readers and DuckDB depend on it to read the parts of a large object they
need without downloading all of it.
Presigned URLs
A presigned URL is a normal URL with a signature and an expiry in its query string, computed locally from your secret key. Anyone holding it can do that one operation until it expires, with no credentials:
url = c.generate_presigned_url("get_object",
Params={"Bucket": "app-data", "Key": "logo.png"}, ExpiresIn=60)
urllib.request.urlopen(url).read() # {"key": "logo.png"}This is how browsers upload and download directly to object storage
without the bytes passing through your application servers: the app checks
permissions, signs a URL for put_object or get_object, and hands it to
the client.
Lab
- Run
s3_basics.py. Then listapp-datawith the AWS CLI using--delimiter /and without it. - Upload a 100 MB file with
aws s3 cpand look at its ETag. How many parts did the CLI use? - Generate a presigned URL with a 10-second expiry, wait 15 seconds, and fetch it. What error do you get?