Decision: choose the simplest object store that can keep every upload private, issue short-lived signed URLs only after tenant authorization, and support a deletion ledger that covers both source files and exports. S3 compatibility is useful, but retention behavior is the harder contract to replace.
For a B2B SaaS app, imagine that each tenant uploads product images and occasionally requests a ZIP export. The data flow is small: the app accepts metadata, places bytes under an opaque tenant-scoped key, records policy in its own database, and later asks a storage adapter for a temporary download URL. The export is a new object with its own expiry. Deletion is an application workflow, not a bucket setting somebody remembers to configure.
Keep that boundary boring.
Reliability starts with an expired tenant export
Start with an invariant: the browser never decides which tenant owns an object. A user presents an application session; the application resolves the tenant, checks permission against its metadata row, and only then creates a signed URL. A URL is a delivery capability, not an authorization system. Anyone holding it may be able to use it until it expires, so don't put one in analytics events, support transcripts, or durable application logs.
The storage key should be opaque and derived by trusted code. A shape such as tenants/{tenantId}/assets/{assetId}/source helps operations, but the prefix alone does not prove access. The database row remains authoritative for tenant ownership, state, retention class, original filename, and content type. That separation also makes an S3-compatible alternative less disruptive: business rules stay above the adapter instead of leaking into provider-specific bucket policy.
Use a private default. Public product pages can still receive intentionally published derivatives through a separate path and policy, while source images and tenant exports remain private. Mixing public and private objects under one loosely interpreted rule is cheap at first and expensive during an access review. Trace a single export all the way through: tenant acme owns 40 product-image rows, an admin requests an archive, a worker reads only those authorized source keys, and the completed archive gets a new object ID plus a deletion deadline. When that deadline arrives, the reconciler marks the export pending, deletes its storage key, and records completion without changing the source-image rows. This trace exposes a surprising number of design errors before any vendor comparison does: borrowed source permissions, exports with no owner, permanent download capabilities, and deletion jobs that cannot say what they finished.
The filename needs care too. When the app serves an export, it can set Content-Disposition so the client treats the response as a download and receives a useful filename. MDN documents both filename and the encoded filename* parameter; sanitize application-supplied names before they become response metadata. The object key doesn't need to resemble the filename at all.
The storage adapter stays deliberately small
The following TypeScript is a runnable policy core, not a vendor SDK tutorial. It models a product-image source and a generated tenant export, rejects cross-tenant access, caps a download grant at 15 minutes, and produces deletion work when either a user request or a retention deadline makes an object due. The adapter is deliberately small so a local test double and an S3-compatible implementation can obey the same application contract.
import assert from "node:assert/strict"; type ObjectKind = "product-image" | "tenant-export"; type ObjectState = "active" | "deletion-pending" | "deleted"; type StoredObject = { id: string; tenantId: string; key: string; kind: ObjectKind; state: ObjectState; deleteAfter: Date | null; }; type DownloadRequest = { tenantId: string; objectId: string; requestedTtlSeconds: number; }; interface PrivateObjectStore { createSignedDownload(input: { key: string; expiresInSeconds: number; downloadName: string; }): Promise<URL>; deleteObject(key: string): Promise<void>; } const MAX_DOWNLOAD_TTL_SECONDS = 15 * 60; function authorizeDownload( request: DownloadRequest, object: StoredObject, ): number { assert.equal(object.id, request.objectId, "object lookup mismatch"); assert.equal(object.tenantId, request.tenantId, "tenant access denied"); assert.equal(object.state, "active", "object is not available"); const ttl = Math.min(request.requestedTtlSeconds, MAX_DOWNLOAD_TTL_SECONDS); assert(ttl > 0, "expiry must be positive"); return ttl; } function deletionIsDue(object: StoredObject, now: Date): boolean { if (object.state === "deletion-pending") return true; return object.deleteAfter !== null && object.deleteAfter <= now; } async function deleteDueObject( store: PrivateObjectStore, object: StoredObject, now: Date, ): Promise<StoredObject> { if (!deletionIsDue(object, now) || object.state === "deleted") return object; await store.deleteObject(object.key); return { ...object, state: "deleted" }; } const image: StoredObject = { id: "asset_01", tenantId: "tenant_acme", key: "tenants/tenant_acme/assets/asset_01/source", kind: "product-image", state: "active", deleteAfter: null, }; assert.equal( authorizeDownload( { tenantId: "tenant_acme", objectId: "asset_01", requestedTtlSeconds: 3600 }, image, ), 900, ); assert.throws(() => authorizeDownload( { tenantId: "tenant_other", objectId: "asset_01", requestedTtlSeconds: 300 }, image, ), ); This code makes two policy decisions visible: 900 seconds is an application maximum, and deletion has a durable intermediate state. Those values aren't universal standards. A finance team exporting a catalog to a slow downstream process may need a longer grant, while an interactive admin download can use less. Pick the value from the actual transfer path, then test it under the largest allowed export.
The production implementation needs a metadata transaction around the storage calls. On a delete request, mark the row deletion-pending first, enqueue work using the object ID, delete the object through the adapter, and record completion. Retries should read the current state. This prevents a crashed worker from turning one lost response into an object that nobody checks again.
Exports deserve separate rows. They combine many source objects, may reveal a tenant's catalog in one download, and usually have a shorter useful life than the originals. Give each export an expiry when it is created, bind its download authorization to the requesting tenant, and delete it independently. Don't infer its lifecycle from the youngest image inside the archive.
Cost follows two retention clocks
An object store can look interchangeable during upload and still impose a very different operational burden. Evaluate the entire lifecycle with a small acceptance suite: upload a private object, deny another tenant, issue and expire a download, request deletion, retry deletion, create an export, expire that export, and verify the final metadata state. Run the same suite against every adapter you are seriously considering.
The decision table is short because most startup apps don't need a feature census. Retention determines how many byte-hours accumulate, while export behavior determines how often the same logical dataset is written and downloaded. Those quantities belong beside access and deletion evidence, not in a separate spreadsheet that assumes every object lives forever:
| Requirement | Evidence to collect | Reject the option when |
|---|---|---|
| Private access | A new object is unreadable without an authorized grant | Public access is the convenient default |
| Signed delivery | The app controls expiry and download response metadata | Authorization must be embedded in permanent URLs |
| Tenant isolation | Cross-tenant tests fail before a URL is issued | Ownership depends only on a user-supplied key prefix |
| Retention | Source and export deadlines can be represented separately | One bucket-wide rule is the only usable policy |
| Deletion proof | A job can reconcile requested, attempted, and completed deletion | The app cannot distinguish pending work from completion |
| Portability | One narrow adapter covers upload, signing, metadata, and delete | Business policy requires provider-specific calls everywhere |
How should a startup app compare private file storage and signed URLs?
Compare the lifecycle evidence, not the length of a feature page. The catch is that S3 compatibility doesn't mean identical lifecycle semantics, identity controls, observability, or billing dimensions. It usually lowers the amount of adapter work; it doesn't eliminate qualification. I'm not sure any paper comparison can settle the fit for a particular export size and user geography. A timed transfer test, followed by deletion and an access check, resolves more than a long feature matrix.
Management models shift work rather than removing it. Self-hosting transfers upgrades, capacity, backups, and recovery tests to the application team. A hosted alternative transfers more infrastructure work to an operator, yet the app still owns tenant authorization and its deletion ledger. An existing stack integration can reduce identity and observability work. None of these boundaries rescues a weak ownership model, and a small team should reject any operating model whose recurring duties it cannot test.
Cost matters, just not as a headline number. Model stored bytes over the retention window, request volume, export amplification, download traffic, and the labor needed to investigate deletion. Published commercial terms can change, so a forecast needs a dated source rather than a number copied into architecture notes. Your mileage may vary sharply if one tenant repeatedly exports the same catalog.
Developer experience means making deletion lag visible
The developer experience should make the correct lifecycle easier to ship than a shortcut. Deployment starts with a deny-by-default policy and a migration plan for metadata, not with a public demo bucket. In staging, seed two tenants and make cross-tenant download attempts part of the release check. In production, log object IDs and tenant IDs rather than signed URLs. Track counts and age for deletion-pending rows, export objects past deleteAfter, authorization denials, and signing latency. Alert on backlog age rather than on a single failed attempt, because retryable work is normal but stale deletion work is a policy breach waiting to happen.
Deletion lag is the signal.
Recovery changes the meaning of deletion. Decide whether a delete request covers only the live object, historical backups, or both, and document any delayed purge window that recovery media imposes. Then make support, legal, and engineering use the same definition. The app should never promise immediate erasure if the operating procedure says otherwise.
Before launch, read the flow as one sentence: authenticated tenant creates a private image, metadata records ownership and retention, an authorized request receives a bounded signed URL, an export gets its own deadline, and a reconciler proves deletion reached a terminal state. Check the negative path after every policy or adapter change. Review old pending rows on a schedule. Re-run the full lifecycle test before switching an S3-compatible backend.
That's the simple version. It has more states than a direct upload demo, but every state answers an operational question you will otherwise face with weaker evidence: who owns this object, who can fetch it now, why does it still exist, and has deletion actually finished?
