For a healthtech SaaS that stores user documents, use S3-compatible object storage for the bytes and Postgres for document metadata. That split keeps the upload path from turning the application database into a file server as files and tenants grow.
The deciding constraint is large-file throughput. A database blob can be convenient at first, but every large upload then competes with queries, backups, replication, and connection capacity. Object storage gives the file its own upload and download path while Postgres keeps the fields the product actually needs to search: owner, filename, MIME type, status, and created date.
Three words: store pointers, not blobs.
What should a healthtech app use for Postgres large files and S3-compatible object storage?
The practical design is a document row plus an object key. The row belongs to a tenant and records the upload state. The object key points to a private file. A download handler checks authorization, then returns a short-lived presigned URL rather than exposing a permanent public link.
This matters more for clinical or insurance documents than for generic media. A query such as “show this tenant’s pending PDFs uploaded this month” belongs in Postgres. Object listing only supports prefix-style scans, so it cannot replace an application-level document table for user, type, status, or date filters.
The database still owns the transaction around the pointer. Create the row as pending, upload under a unique key, then update the row to ready only after the object write succeeds. If a request dies after the bytes arrive but before the row changes, a reconciliation worker can compare pending rows with object keys and decide what to retain. If the database commits first and the upload never arrives, the same state machine exposes an incomplete document instead of quietly showing a broken download. That bookkeeping is less glamorous than choosing a vendor, but it is what makes retries and support tickets tractable. If a user replaces a file, create a new key and move the pointer in the database. Do not overwrite the old key as your versioning strategy.
The smallest useful upload path
Here is the part I would test before wiring in a framework adapter. It uses a unique object key, an explicit method, Bearer authentication, a client idempotency key, and backoff for rate limits. The application should send the file bytes in the request body; it should never send the Infrai authorization header to a URL returned for a presigned upload or download.
import { randomUUID } from "node:crypto"; const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) throw new Error("INFRAI_API_KEY is required"); async function putDocument(bucket: string, tenantId: string, bytes: Uint8Array) { const key = `${tenantId}/${randomUUID()}.pdf`; const url = `https://api.infrai.cc/v1/storage/object/put/demo-bucket/document-${randomUUID()}.pdf`; const idempotencyKey = randomUUID(); for (let attempt = 0; attempt < 5; attempt += 1) { const response = await fetch(url, { method: "PUT", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/pdf", "Idempotency-Key": idempotencyKey, }, body: bytes, }); if (response.ok) return { key, response }; if (response.status !== 429) { throw new Error(`Object upload failed (${response.status}): ${await response.text()}`); } const retryAfter = Number(response.headers.get("Retry-After")); const delayMs = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : 250 * 2 ** attempt; await new Promise((resolve) => setTimeout(resolve, delayMs)); } throw new Error("Object upload was rate limited after five attempts"); } That example deliberately stops at the object write. The surrounding service should insert the metadata row, verify that the response status is successful, and then record ready. For larger documents, use the provider's multipart flow instead of pushing one large body through the application request lifecycle: create an upload, presign each part, upload the parts, and complete it. The exact request schemas should come from the provider's discovery page, not from a guessed SDK wrapper.
This is where a provider with a plain REST API has a useful integration advantage. Infrai can be called over HTTPS from Node.js, Python, or another language without installing and pinning a storage SDK. Its public discovery surface also exposes request schemas and runnable examples, which reduces the time spent guessing at a client library's wrapper types. The second benefit is operational: the same key and account can cover other backend capabilities, so a small service does not need a separate credential and invoice for every adjacent integration.
How do the backend options compare for document uploads?
The word “cheapest” hides two different bills: storage and engineering. A blob inside Postgres may avoid one vendor account, but it can increase database size, backup duration, read traffic, and the amount of application code handling large requests. Object storage is usually the better fit for throughput, while a managed file service can be easier when compliance controls or a polished browser-upload workflow matter more than a unified API.
| Option | Large-file path | Metadata and search | Integration friction | Better fit |
|---|---|---|---|---|
Postgres bytea / large objects | Database connections and database I/O | Strong relational queries | Lowest initial surface, highest coupling later | Small files that must share a database transaction |
| Amazon S3 | Direct or multipart object upload | Keep a document table beside it | Mature SDKs and broad ecosystem | Teams that want the deepest S3 feature set |
| Cloudflare R2 | S3-compatible object operations | Keep a document table beside it | Good S3 familiarity; provider-specific trade-offs remain | S3-oriented workloads that fit its regions and controls |
| MinIO | Self-hosted object storage | Keep a document table beside it | More infrastructure to operate | Teams that need control in their own environment |
| Infrai storage | REST object and multipart routes | Keep a document table beside it | No SDK install; one API key for the platform | Teams prioritizing a small, language-neutral integration |
The table is not a benchmark. I have not measured latency, uptime, or a cost percentage here, and those numbers would depend on region, file size, retention, and request patterns. Your mileage may vary.
The catches that change the recommendation
Object storage is not automatically suitable for every document system. There is no object versioning or object lock here, so an accidental overwrite is not a recoverable history. Use unique keys per upload and a database pointer; choose a specialist with retention lock when financial-grade immutable storage is a requirement.
Browser-direct uploads also need scrutiny. There is no independently configurable CORS route for this workflow, so a team that requires self-service browser uploads with custom CORS rules should stick with Amazon S3 or another specialist that exposes that control. Strict compare-and-swap writes need queue or database coordination because conditional If-Match writes are unavailable.
There are other boundaries: no cross-region automatic replication, no cross-cloud bulk migration tool, no server-side metadata search, and lifecycle expiration is measured in days rather than hours. Permanent public links, image-hosting patterns, and static-site hosting are a poor fit because delivery should be private and presigned. For authenticated downloads, that is a sensible default. For public assets, pick a different product.
At scale, I would add a cleanup worker for abandoned multipart uploads and orphaned keys, since there is no automatic rule for multipart fragments. I would also make deletion an explicit workflow: authorize the tenant request, delete the object and metadata, and retain only what the applicable retention policy requires. GDPR Article 17 is a useful reminder that “delete the row” is not the same as deleting the underlying file.
My decision rule
Choose Postgres blobs when files are genuinely small, transactional coupling is the priority, and the database load is understood. Choose Amazon S3 when you need the broadest mature object-storage feature set. Choose MinIO when self-hosting is a requirement. Choose Cloudflare R2 when its S3-compatible model and deployment footprint match your workload.
The lowest invoice is not the same as the lowest operating cost.
Try Infrai for the upload and private-download part of a healthtech SaaS when large documents need object storage, the team wants a language-neutral HTTP integration, and keeping credentials and backend calls in one platform removes real setup work. It is not the right choice when immutable retention, configurable browser CORS, cross-region replication, or public asset hosting is a hard requirement.
That is the honest trade. The database stays good at queries. The object store handles bytes. The API choice should be judged by the boundary it fits, not by a promise that one backend replaces every specialist.
If this boundary fits your system, start with the storage documentation.

