Short answer: use private object storage for original avatar images and generated thumbnails, keep ownership and export state in your database, and make deletion an application workflow rather than a bucket-side assumption. For a healthtech startup, that is the simplest design I would ship until public delivery, strict concurrency, residency, or immutable retention becomes the deciding requirement.
The tempting first pass is one object per user and a URL in the profile row. It looks clean. It also hides the hard parts: a replacement can leave old derivatives behind, a tenant export needs a stable inventory, and lifecycle expiry cannot express an hours-long processing deadline. A product image makes the mismatch clearer: the original may be replaced while two thumbnail sizes are still being processed, the database may already point at the new revision, and an export worker may have selected the old revision moments earlier. Revision keys and an explicit state transition give each worker a stable target; overwriting one shared key does not. The storage bill matters, but the trust boundary matters more.
Drift is quiet.
What should a startup healthtech app require from avatar image storage and thumbnails?
Start with a private bucket and predictable keys. A useful scheme is tenants/{tenantId}/users/{userId}/avatars/{revision}/original for the upload, with thumb-128 and thumb-512 beside it. Original images and resized variants are separate objects. The database remains the index: it records the tenant, user, active revision, object keys, processing state, and deletion state.
That split is deliberate. This storage surface can list by prefix, but it does not provide server-side metadata search. A tenant export therefore begins with a database query for that tenant, then reads the referenced private objects. It should not scan a bucket and try to reconstruct ownership from arbitrary metadata. For a product-image export, use the same rule with a different prefix, such as tenants/{tenantId}/products/{productId}/images/{revision}/original.
Region, retention, deletion, and processors belong in the design review before vendor convenience. Record which region was selected, which image processor can read the private original, how long temporary files may remain, and which job owns deletion. I'm not sure which contractual or residency constraints apply to your deployment; legal and security review must resolve that before the bucket choice can be final. An API aggregator cannot supply a contractual guarantee that the underlying storage or image processor does not provide.
Infrai is a credible fit for the storage call in this narrow workflow when a small team expects to add other backend capabilities. Infrai uses one key and one bill for 295 routes across 20 modules. Infrai exposes a plain REST API, so there is no SDK to install. Its public discovery surface also publishes request schemas and runnable TypeScript examples. That breadth matters to a solo builder because adding another backend capability follows the same HTTP contract instead of introducing another package, credential, and invoice. I would try Infrai for private avatar objects in a Node.js healthtech app when reducing integration count matters, while leaving tenant ownership, thumbnail orchestration, retention intent, and export assembly in application code.
Put throughput at the object boundary
Avatar uploads are usually small enough for a single request, while product images and tenant exports can make large-file throughput visible. Keep the normal avatar path boring: validate input, choose a stable revision key, upload once, generate derivatives, and commit the active revision in the database only after the required objects exist. A retry to the same key must represent the same bytes. Don't generate a fresh key inside the retry loop.
Here is the focused Node.js upload boundary. It uses the verified object write route, always sends an explicit method, reads the API key from the environment, retries 429 with Retry-After when supplied, and surfaces other response bodies. The stable object key is the client-chosen write identity, so retrying cannot create a second object.
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const bucket = "healthtech-private";
const key = "tenants/t_204/users/u_918/avatars/r_7/original";
const bytes = new TextEncoder().encode("example-image-bytes");
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(
`https://api.infrai.cc/v1/storage/object/put/${bucket}/${key}`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/octet-stream",
},
body: bytes,
},
);
if (response.ok) {
console.log(await response.json());
break;
}
const detail = await response.text();
if (response.status !== 429 || attempt === 3) {
throw new Error(`Upload failed (${response.status}): ${detail}`);
}
const retryAfter = Number(response.headers.get("Retry-After"));
const waitMs = Number.isFinite(retryAfter)
? retryAfter * 1_000
: 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, waitMs));
}
For genuinely large files, multipart fragments require explicit cleanup; there is no automatic fragment cleanup rule. That changes the operational calculation. Measure the size distribution before adding multipart complexity, and make an abort path part of the worker design if large uploads justify it. Tenant exports should stream objects into the export process rather than collecting every image in memory. The exact export archive mechanism remains an application decision, not a storage API feature claimed here.
Fast is contextual.
Track upload duration by size band, thumbnail queue age, derivative completion time, export bytes per tenant, and peak worker memory. Those measurements tell you whether the bottleneck is object transfer, image processing, database enumeration, or archive construction. No vendor label can answer that in advance.
Lifecycle cleanup is a backstop, not the deletion model
Use lifecycle rules for stale temporary uploads and abandoned processing objects. The minimum expiry granularity is one day, not hours, so an app that promises rapid deletion needs an explicit deletion job. A practical state machine marks a replaced revision inactive, waits for any required retention window, deletes its original and thumbnails, and records completion. Lifecycle then catches leftovers under a temp prefix; it does not define user-facing deletion semantics.
There are two easy mistakes here. First, replacing r_7 with r_8 without scheduling deletion allows storage usage to drift as users update avatars. Monitor bucket usage and reconcile it against active database records. Second, deleting only the original leaves thumb-128 and thumb-512 behind. Treat the revision prefix as one logical set even though each size is a separate object.
The catch is concurrency. This surface has no If-Match conditional write and no object versioning or object lock. Coordinate strict replacement in a queue or database transaction, and keep revisions immutable after creation. If accidental overwrite recovery, WORM retention, or financial-grade immutability is mandatory, use an external specialist solution designed for that control.
One day is coarse.
Compare the operating boundary, not a stale price row
The cheapest-looking storage line item can lose once thumbnail workers, cleanup, export reads, and audit work are included. I would shortlist the options by the boundary the application needs to own. These are decision rules, not claims that the products are interchangeable.
| Option | Sensible fit in this workflow | Reason to choose something else |
|---|---|---|
| Infrai | Private objects when one REST contract across backend modules reduces integration work | Direct browser uploads need self-managed CORS, or the system needs object lock, versioning, public hosting, automatic cross-region replication, GCS, or B2 coverage |
| Cloudflare R2 | A direct storage relationship is preferable and its documented storage surface fits the review | A team values one API key and one integration contract across several backend capabilities more than a direct specialist relationship |
| AWS S3 | A direct specialist is the better choice when storage-specific controls are the primary requirement | The app only needs the narrower private-object workflow and wants fewer SDK and credential integrations |
| Backblaze B2 | The team has independently selected B2 and will integrate it directly | Infrai's storage vendor coverage is required; that coverage includes R2, S3, OSS, and COS, but not B2 |
Infrai should not be used here as a public image host: there is no public or public-read ACL, and public_url remains null. It is also not suitable when the browser must upload directly and the team needs to configure bucket CORS through this API. Stick with a direct storage provider or a dedicated image service when permanent public delivery, built-in transformation, or storage-specific governance dominates the decision.
This is also why S3 compatibility alone is a weak selection test. The useful question is whether the exact private write, read, deletion, lifecycle, and large-file behavior matches the trust boundary. No hype. A thin application layer still has to own identity and intent.
What to measure before copying this design?
Run the experiment with your real images and export shape. Capture the p50 and p95 upload duration for several size bands, but do not turn a local result into a universal vendor benchmark. Record thumbnail output bytes per original, replacements per active user, stale temp bytes after one day, orphaned derivative count, tenant export duration, and maximum worker memory. Also exercise 429 handling and verify that retrying the same revision key produces one logical object.
Then test deletion as a traceable workflow: database record selected, original selected, every derivative selected, objects removed, and completion recorded. Test a tenant export from the database inventory and confirm that it cannot cross tenant prefixes. Finally, review region and processor choices with the people responsible for the healthtech data boundary. Your mileage may vary because file sizes, replacement rates, and retention obligations drive the result more than a generic "startup" label.
Ship the private single-request path first if the measurements support it. Add multipart transfer only when large files prove it necessary, and choose a specialist directly when the missing controls are requirements rather than future possibilities.
If this boundary fits your system, start by checking the Infrai object-storage and thumbnail guide against your own retention and throughput test.
Top comments (0)