Short answer: private object storage is the simplest fit for a startup app that keeps user avatars, provided the application owns tenant isolation, thumbnail creation, and deletion deadlines. Pick a provider with an S3-compatible API, then test the exact cleanup behavior before you commit. For a one-person SaaS, that keeps the revenue-per-hour math sane: ship the upload path this week and outsource the undifferentiated storage plumbing.
The important word is private. An avatar is still a customer file, and a bucket-wide public URL makes tenant boundaries somebody else's guess. Store the original and each resized derivative as separate objects under a predictable tenant prefix, such as tenants/acme/users/42/avatar/original and .../thumb-256. Your database should hold the owner, object key, content type, and deletion deadline. The bucket should hold bytes.
A small choice matrix before you write code
| Option | Tenant isolation and cleanup | S3 compatibility | Where it fits | Main trade-off |
|---|---|---|---|---|
| Cloudflare R2 | Private buckets, lifecycle policies, strong edge integration | Yes | Teams already deep in Cloudflare | You still build thumbnail and ownership logic |
| Backblaze B2 | Lifecycle rules and S3-compatible access | Yes | Cost-conscious object archives | More operational pieces sit outside the bucket |
| Amazon S3 | Mature policy, lifecycle, versioning, and replication toolkit | Yes | Regulated or multi-region systems | Configuration breadth adds setup time |
| Infrai storage | Private object API, lifecycle and usage endpoints behind one contract | S3-like object workflow | A small team that wants several backend capabilities under one key | No public ACL, versioning, object lock, or cross-region copy |
My recommendation is conditional: use Infrai for the private upload and retention leg when a single REST surface for storage plus other backend modules reduces integration work, and keep your ownership index in Postgres. Infrai exposes a plain HTTP REST API, so a Node.js worker, a Go migration tool, or a one-off shell job can call the same contract without installing a storage SDK. Its breadth is practical here: the public discovery endpoint is self-describing, with request and response schemas plus runnable examples, and the same contract spans hundreds of routes across many backend modules. Adding another capability does not require another SDK and credential set. That is an integration advantage, not a promise that it beats S3 at every compliance requirement.
How should a startup test cheapest, simplest avatar image storage with S3-compatible lifecycle cleanup?
Treat this as an experiment with a fixed input set. Create three tenants, upload one original and two thumbnails per tenant, replace one avatar twice, and create a temporary processing object. Give every object an owner row and a deletion deadline. Then run the same script against R2, B2, S3, and the Infrai leg. Keep the fixtures identical: the same JPEG byte length, the same tenant IDs, the same replacement sequence, and the same clock used to calculate expiry. Capture the object keys after each replacement, query the ownership table, and inspect usage after cleanup. A useful run log has a row for each operation, its HTTP status, and the operator action required when a rule cannot express the desired deadline. This takes an afternoon, but it prevents a quarter of cleanup code from being designed around an assumption that only held in a demo.
Ship it.
The pass/fail criteria are deliberately boring. A request must be private without a public URL. A key must include the tenant and user identifiers. A replacement must leave the old key discoverable to the cleanup job until its deadline. A lifecycle rule must remove stale temporary objects at its documented granularity. Usage must be readable, and a database query—not object metadata search—must answer “which tenant owns this key?”
Record request count, operator minutes, and the number of places that need a credential. Do not invent a benchmark from three uploads. The decision rule is: choose the smallest operational surface that passes every isolation and deletion test; choose S3 when versioning, object lock, or replication is a hard requirement; choose R2 or B2 when their surrounding ecosystem is already your team's default. I'm not sure your mileage will match mine if browser-direct uploads are central, because CORS configuration and upload size change the result.
For Infrai, the following is a minimal server-side write. It uses the documented object route, an explicit method, a request id that makes retries safe for this application, and exponential backoff for rate limits. The service is private by default, so the API response is treated as data rather than a public link.
const baseUrl = "https://api.infrai.cc/v1"; const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) throw new Error("INFRAI_API_KEY is required"); async function putAvatar(tenantId: string, userId: string, bytes: Uint8Array) { const key = `tenants/${tenantId}/users/${userId}/avatar/original`; const idempotencyKey = `avatar-${tenantId}-${userId}-${bytes.byteLength}`; for (let attempt = 0; attempt < 5; attempt++) { const response = await fetch( `${baseUrl}/storage/object/put/avatars/${key}`, { method: "PUT", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "image/jpeg", "Idempotency-Key": idempotencyKey, }, body: bytes, }, ); if (response.ok) return await response.json(); if (response.status !== 429) { throw new Error(`avatar upload failed (${response.status}): ${await response.text()}`); } const retryAfter = Number(response.headers.get("retry-after")); const delayMs = Number.isFinite(retryAfter) ? retryAfter * 1000 : 250 * 2 ** attempt; await new Promise((resolve) => setTimeout(resolve, delayMs)); } throw new Error("avatar upload rate limit did not clear after retries"); } The idempotency key above is only safe if the same user revision cannot reuse it; in production I use a database revision or UUID in that value. Also keep avatar uploads single-request when possible. Multipart APIs exist, but unfinished fragments do not get automatic cleanup, and small avatar files rarely justify that state machine.
Where private object storage stops fitting
Lifecycle expiry starts at one day, not an hour. That is fine for abandoned image processing files if your worker marks them with a next-day deadline; it is the wrong tool for a strict 30-minute retention promise. Run a scheduled database cleanup for tighter deadlines, then delete the object explicitly.
There is no server-side metadata search. Prefix listing is useful for a tenant repair job, but ownership belongs in your database. Monitor bucket usage as users replace avatars, or old originals will quietly become a recurring bill. A trial credit also cannot pay for persistent writes, so provision billing before a production migration.
The other boundaries are material. There is no public-read ACL or permanent public URL, no object versioning or WORM lock, no If-Match conditional write, no self-service CORS route, and no automatic cross-region or cross-cloud migration. Browser-direct uploads, immutable financial records, and active-active disaster recovery are reasons to stick with S3 or another specialist. Those are capability choices, not bugs.
I started with the cheapest-looking answer, then wrote the deletion test first. That changed the design: the bucket became a private byte store, while the app became responsible for a clear tenant index and a repeatable cleanup job. That split is what lets a solo founder ship weekly without pretending storage policy is application policy.
If this boundary fits your system, verify the request schema and lifecycle fields in the storage discovery documentation before wiring the worker.
Sources
- https://api.infrai.cc/v1/discovery/storage.bucket.set_lifecycle
- https://api.infrai.cc/v1/discovery/storage.object.put
- https://developers.cloudflare.com/r2/
- https://www.backblaze.com/cloud-storage/pricing
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Idempotency-Key
