
An object-store bucket is not a desktop folder tree. It is a flat collection of object keys; the slash-separated ‘folders’ in clients are prefixes inferred from those names. A consistent key scheme makes browsing, lifecycle work, permissions, recovery and bulk operations less error-prone long before a bucket reaches 10,000 files.
Start with a key, not a folder
A key uniquely identifies an object. AWS’s S3 documentation sets a maximum key length of 1,024 UTF-8 bytes and notes that keys are case sensitive. The complete prefix counts toward that limit. This is plenty for normal names, but it is a reason to keep generated paths structured rather than embedding an entire URL or customer record in every filename.
Why the date comes before the filename
S3-compatible listing APIs select objects by prefix and return key names in UTF-8 binary order. A zero-padded YYYY/MM/DD prefix therefore makes ‘all files for 1 November’ a direct prefix query and makes chronological browsing natural. Put the lowest-cardinality grouping first: an area such as media, exports or backups; then a tenant or project; then time. Put a random or stable identifier after the part you need to browse.
| Question | Key design | Prefix to list |
|---|---|---|
| Restore one website on a date | backups/site-a/2026/11/01/… | backups/site-a/2026/11/01/ |
| Find one customer's exports | exports/acme/2026/11/… | exports/acme/ |
| Purge generated thumbnails | media/acme/2026/11/…-thumb.webp | media/acme/ plus a suffix filter in your app |
| Keep originals and derivatives separate | originals/… and derivatives/… | originals/ or derivatives/ |
The 10,000-file example
Suppose an app creates 10,000 images in one month for 50 customers: 200 per customer. With media/<customer>/2026/11/<id>-original.jpg, a customer browse begins with one bounded prefix instead of scanning the whole collection. Listing is still paginated: AWS documents up to 1,000 keys per list response. A full bucket scan of 10,000 objects needs at least 10 pages; one 200-object customer prefix can fit in one page. Always implement the continuation token even when the first data set is small.
Use characters that survive tools and URLs
Use lowercase letters, digits, hyphens, underscores and periods for generated segments; use / only as a delimiter. AWS calls alphanumeric characters, !, -, _, ., *, apostrophe and parentheses generally safe. It specifically warns that spaces and URL-sensitive characters can require special handling, and recommends avoiding period-only . and .. path segments because applications may normalize them.
| Avoid in generated keys | Reason | Safer replacement |
|---|---|---|
| Spaces and repeated spaces | URL and copy/paste handling | hyphens |
| ./ or ../ segments | path normalization | a named segment such as previous |
| %, #, ?, brackets | encoding or URL fragment/query meaning | lowercase words and hyphens |
| mixed-case identifiers | keys are case-sensitive | one lowercase convention |
Keep human labels out of the only identifier
A filename like final-final-v7.jpg cannot reliably tell an app whether it is unique. Use an immutable ID and retain a human display name in object metadata or your application database. If a path has to be public, avoid personal data, email addresses and secrets in the key: a public URL often exposes the key itself. Changing a key is normally a copy-and-delete workflow, so treat key design as part of the data model.
A migration you can stop safely
- Write the new key rule and test it with 20 representative files, including non-ASCII filenames and files with spaces.
- Copy objects to the new prefix; do not delete the originals yet.
- Compare object count, total bytes and a sample of hashes or checksums.
- Point new writes at the new prefix and update readers that know the old paths.
- After a documented retention period and a restore test, delete only the verified old prefix.
The existing rclone backup guide is a good way to copy and check a migration. If you are configuring a client for an S3-compatible endpoint first, read S3-compatible storage explained.
Use organized buckets with familiar S3-compatible clients.
Explore tport.space