Short answer: choose object storage for SaaS user documents by the tenant-isolation, recovery, and link-revocation rules your media SaaS can actually operate; the advertised capacity rate is a late filter, not the architecture.
That is a less convenient answer than naming the cheapest service. A user document is private because the application authorized access to it, not because its object key looks obscure. The storage layer must preserve that decision through upload, download, overwrite, deletion, and recovery.
Governance rules for SaaS user document storage
Start with an architecture decision record containing four invariants: every object maps to one application document and one tenant; browsers never receive storage credentials; every signed download follows an authorization check; and deletion or overwrite has a documented recovery owner.
For a media SaaS, the record might identify tenant_42, document doc_7f3, and the server-derived key tenants/tenant_42/documents/doc_7f3.pdf. A key is an address, not a permission. The database record holds the tenant, owner, object key, content state, and retention decision. A request that accepts a complete client-supplied key has already made the namespace part of its security model, which is a poor place to hide authorization; that shortcut can turn a harmless-looking lookup into a cross-tenant read when identifiers from two records are mixed during a retry or a rename.
No shortcut.
I would also define the failure response. A missing document and a document belonging to another tenant should normally look the same to the caller; the internal audit event can still record a tenant ID, document ID, and authorization result. A 403 is not a storage policy. It is the application saying that its check failed.
How do private files survive deletion, overwrite, and restore failures?
Reliability is where the provider comparison becomes concrete. Ask what happens when a user replaces a PDF while a download is in flight, when an upload is abandoned halfway through, or when an operator deletes the wrong object. Then test the answer in the deployment environment.
| Concern | Question to answer | Evidence to require |
|---|---|---|
| Isolation | Can a server-side document lookup precede every signed request? | Cross-tenant and substituted-key tests |
| Durability | What restores a deleted or overwritten file? | A recorded restore exercise |
| Retention | Who owns expiry, deletion, and legal-hold decisions? | A policy with an operator and timestamp |
| Browser access | Which origins and headers may make cross-origin requests? | CORS configuration and preflight tests |
| Portability | Which API details differ across S3, Cloudflare R2, DigitalOcean Spaces, and Backblaze B2? | An adapter contract tested against each target |
S3-compatible does not mean operationally identical. Multipart cleanup, versioning, lifecycle behavior, consistency promises, signed-request canonicalization, and billing units still belong in the evidence column. I am not sure which provider wins for a given tenant mix without a trace of retained bytes, uploads, downloads, transfer, failed multipart sessions, and restore work. Your mileage may vary.
The catch is that a generic private-file pattern is not suitable when immutable retention, a specific legal-hold control, or an immediate revocation guarantee is mandatory. In that case, choose the storage design whose enforced controls match the requirement, even if its adapter is less portable. Stick with a public delivery path when the files are intentionally public; do not weaken a private path to make browser delivery easier.
Can SaaS user documents migrate between private object storage providers?
Treat migration as a first-class workflow, not a future rewrite. The application record should remain authoritative while a copy job transfers bytes, verifies metadata and checksums where supported, and records a source and destination key. Downloads can continue through the application during the copy, so a provider change does not require changing every document URL at once.
The migration gate is not “the SDK call returned success.” It is a reconciliation report: records with no object, objects with no record, mismatched content metadata, and files that cannot be restored. Keep the storage adapter narrow. Its contract needs operations such as put, get metadata, issue a scoped download capability, copy, and delete; provider-specific behavior stays behind that boundary.
This is also where cost claims need discipline. Compare retained capacity, request volume, delivery transfer, replication, recovery, and operator time against the same workload. The question includes S3, Cloudflare R2, DigitalOcean Spaces, and Backblaze B2 because they are plausible candidates, but their names do not establish a winner. A price table without a download trace is a guess. Before a migration starts, run the same representative trace against each candidate: upload a small document, upload a large media file, abandon a multipart session, issue and expire a signed link, download repeatedly, delete an object, and perform a restore. Keep the output beside the ADR. That record exposes a provider mismatch earlier than a production incident, and it gives the team something stronger than a calculator screenshot when the workload or delivery geography changes.
API boundaries for private files and signed download links
A presigned URL is a bearer capability. AWS documents that anyone who receives one can use it until it expires or the underlying permission changes; it should therefore be short-lived, scoped to one object, and created only after the application checks the authenticated tenant and document record.
The browser path has two separate gates. CORS governs whether a browser permits a cross-origin request and which response a page may read; it does not authorize a tenant. MDN's CORS guide explains that browser policy separately from the server's access decision. A backend transfer avoids some CORS setup, but moves streaming and bandwidth into the application.
Here is the critical path with the signer injected. It is deliberately provider-neutral, so the authorization property can be tested without a commercial SDK.
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from typing import Callable
@dataclass(frozen=True)
class Document:
document_id: str
tenant_id: str
object_key: str
DOCUMENTS = {
"doc_7f3": Document(
document_id="doc_7f3",
tenant_id="tenant_42",
object_key="tenants/tenant_42/documents/doc_7f3.pdf",
)
}
def issue_download(
document_id: str,
authenticated_tenant: str,
signer: Callable[[str, datetime], str],
) -> str:
document = DOCUMENTS.get(document_id)
if document is None or document.tenant_id != authenticated_tenant:
raise PermissionError("document is unavailable")
expires_at = datetime.now(timezone.utc) + timedelta(minutes=10)
return signer(document.object_key, expires_at)
def test_cross_tenant_access_is_rejected():
try:
issue_download("doc_7f3", "tenant_99", lambda key, expiry: key)
except PermissionError:
return
raise AssertionError("cross-tenant access was not rejected")
I've kept the test small on purpose. Add cases for expired capabilities, upload-key substitution, CORS preflight, overwrite races, deletion reconciliation, and restore. Never log the signed URL query string; log the document ID, tenant ID, decision, and policy version instead.
Storage cost is a workload property, not a provider ranking
The tempting design gives each browser a bucket-wide credential or lets it choose a complete key, then trusts a prefix such as tenant_42/ to provide isolation. It reduces application code. It also makes a path convention carry a permission it cannot prove.
The valid use case is narrower: accept an opaque client token, map it to a server-created document record, derive the final key on the server, and give the client only the scoped capability it needs. That keeps resumable-upload ergonomics without allowing one tenant to name another tenant's object.
Use the decision rule at the end of the ADR: select the option that can demonstrate isolation and recovery under the measured media workload. Change providers when the evidence changes, not because a rate card makes a stronger promise than the system can verify.
References
- MDN, Cross-Origin Resource Sharing: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- AWS S3, presigned URLs: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
Further reading
- MDN, Cross-Origin Resource Sharing: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- AWS S3, presigned URLs: https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
Top comments (0)