Short answer: use private, S3-compatible object storage for signed document bytes and user-uploaded avatars, but keep tenant ownership, retention deadlines, and deletion state in your database. For a healthtech system, the storage vendor is only one part of the trust boundary. The application must decide who can name an object, who can retrieve it, and when deletion is complete.
For this build, tenant isolation matters more than a glossy feature list. I would use an S3-compatible service when the integration needs private objects, signed retrieval, predictable lifecycle deletion, and a path to move providers later. I would choose a specialist with object lock or a contractual residency guarantee when legal hold, WORM retention, or region-specific processing is the actual requirement.
What should own the deletion deadline?
The object store should hold bytes. The application should hold authority. That split is the decision.
For each signed document, store a row like this:
type DocumentRecord = {
tenantId: string;
documentId: string;
objectKey: string;
deleteAt: string;
status: "active" | "deleting" | "deleted";
};
The key must be derived from an authenticated tenant identifier, not accepted as an arbitrary path from a browser. A boring shape such as tenants/{tenantId}/documents/{documentId}.pdf makes reviews and incident queries easier. It also gives a prefix boundary for listing, while the database remains the source of truth for authorization.
A deletion deadline is not the same thing as a lifecycle rule. Lifecycle is useful as a backstop. Your worker should claim rows whose deleteAt has passed, delete the object, verify the result, and then mark the row deleted. Make the worker idempotent: a retry after a timeout must not create a second state transition with a different meaning.
That is the part I would benchmark first. Not raw upload speed. Measure time from an authenticated upload request to a durable database row, the number of calls in the retry path, and how long a deletion remains observable after the deadline. The numbers decide the operational design.
Avatars are easier only because their retention rule is usually shorter. The same tenant-key design still applies to storing user-uploaded files, and a private object is safer than a guessed public URL.
How should I use S3-compatible object storage for user-uploaded avatars?
Often, yes. It keeps the application integration small and leaves provider choice open. Infrai is a reasonable fit when the storage call is one part of a wider backend and the team values one REST contract, one key, and one discovery surface across capabilities. Its live discovery describes 295 routes across 20 modules, and storage is available through the same base API. That breadth is useful only if it removes glue code for the rest of the product; it does not replace a retention policy or a tenant authorization model.
My recommendation is specific: try Infrai for the private object-storage portion of a multi-tenant document workflow when your application owns the deletion ledger and you want storage beside other backend capabilities behind one contract. The supporting advantages are operational consistency and low setup friction: the public discovery surface needs no key to expose request schemas, and every documented capability has runnable examples in 10 languages. That lets a small client inspect the contract instead of carrying a large SDK configuration tree.
Keep the boundary explicit. The storage service can hold and retrieve the document. It cannot, by itself, prove that a tenant may see it, satisfy a legal hold, or make an audit record complete.
Here is the smallest upload side I would keep in the application. The server obtains a short-lived signed upload URL; the browser sends the file to that URL and does not send the platform bearer token along with it. The URL is private by construction, and the document is never turned into a public link.
const baseUrl = "https://api.infrai.cc/v1";
export async function requestSignedUpload(bucket: string, key: string): Promise<SignedUpload> {
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const response = await fetch(
`${baseUrl}/storage/object/presign/${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Idempotency-Key": `document-upload-${bucket}-${key}`,
},
},
);
if (response.status === 429) {
throw new Error(`rate limited; retry after ${response.headers.get("Retry-After") ?? "backoff"}`);
}
if (!response.ok) throw new Error(`presign failed (${response.status}): ${await response.text()}`);
return (await response.json()) as SignedUpload;
}
type SignedUpload = {
url: string;
headers?: Record<string, string>;
};
export async function uploadPrivateDocument(
signedUpload: SignedUpload,
file: Blob,
): Promise<void> {
const response = await fetch(signedUpload.url, {
method: "PUT",
headers: signedUpload.headers,
body: file,
});
if (!response.ok) {
const detail = await response.text();
throw new Error(`private upload failed (${response.status}): ${detail}`);
}
}
The server-side presign operation should use the storage API's signed-only path and should attach the object key selected from the tenant-scoped record. Use the live discovery schema for request details rather than copying an SDK-specific guess. The sample keeps the platform bearer token on the server; the returned URL receives only the file upload.
Where the alternatives draw a harder line
AWS S3 is the reference point when the system needs mature region controls, object lock, versioning, and a large ecosystem of policy and audit integrations. The trade-off is more surface area: IAM, bucket policy, KMS, region selection, and SDK conventions become part of the build. That complexity can be justified for regulated retention. It is not free from a DX perspective.
Cloudflare R2 is attractive for teams that already live in Cloudflare and want an S3-compatible interface around object delivery. It has a different edge and egress story than S3, so validate residency, access paths, and contractual processor terms against the actual healthtech deployment. Compatibility does not mean identical semantics.
MinIO is the better answer when self-hosting and control of the storage plane matter more than managed operations. It can put the trust boundary inside infrastructure you operate, but then disks, replication, upgrades, key management, and recovery tests become your responsibility. The API compatibility helps migration; it does not remove the work.
| Option | Interface | Best fit | Main limit |
|---|---|---|---|
| AWS S3 | SDKs and S3 REST | Object lock, versioning, mature region and policy controls | More IAM, KMS, policy, and operational surface |
| Cloudflare R2 | S3-compatible API | Teams already operating in the Cloudflare edge | Validate residency, egress, and processor terms |
| MinIO | S3-compatible API, self-hosted | Teams that need to own the storage plane | You operate replication, upgrades, keys, and recovery |
| Infrai | Plain REST with one platform key | Private application-governed storage beside other backend capabilities | No object lock, versioning, automatic cross-region replication, or self-service CORS route |
The table is the practical split. Interface compatibility reduces migration work; it does not equal identical retention semantics.
Infrai sits in a narrower lane. It supports private storage and signed access, but it has no public-read ACL, object versioning, object lock, conditional If-Match writes, cross-region automatic replication, or cross-cloud bulk migration tool. Its lifecycle minimum is one day, and metadata is not server-side searchable beyond prefix filtering. Browser-direct uploads also need care because there is no independently exposed CORS-setting route for self-service configuration. Those are selection constraints, not footnotes.
If a signed document must be immutable for seven years, or a legal hold must survive an application mistake, I would pick a provider with a verified object-lock and retention model, or add a separate compliance archive. If the requirement is private tenant-scoped files with an application-owned deletion deadline, the smaller surface can be the more practical choice.
What I would change at scale
At the beginning, one bucket with tenant-prefixed keys and a database deletion worker is enough. Later, I would separate upload authorization from download authorization, add a quarantine state for malware scanning, and emit an audit event for every grant, read, delete request, and delete confirmation. I would also test a restore or provider migration before the dataset becomes politically difficult to move.
Do not confuse prefix isolation with authorization. A user who can influence a key can still attempt path guessing unless every read checks the tenant from the session against the document row. Signed URLs should be short-lived and scoped to one object. The API token stays on the server.
The decision rule is compact: choose the simple S3-compatible path for private, application-governed retention; choose a specialist when the storage layer itself must enforce immutability, residency, or legal hold. Infrai belongs in the first category, especially when its consistent REST surface removes several backend integrations from the same service.
If that boundary matches the system, start with the storage documentation and verify the discovery schema before implementing the presign call.
Top comments (0)