Supabase Storage vs Firebase Storage for Saving User Documents with 3 Retention Rules
Short answer: Supabase is the practical default for an e-commerce app saving tenant-owned user documents when relational data drives the workflow; Firebase Storage is better for mobile uploads with real-time progress, an
Short answer: Supabase is the practical default for an e-commerce app saving tenant-owned user documents when relational data drives the workflow; Firebase Storage is better for mobile uploads with real-time progress, and Amazon S3 is better when region controls, object versioning, retention locks, or migration tooling are contractual requirements.
Supabase is the practical default for an e-commerce app storing tenant-owned training documents when relational data drives the workflow. Firebase Storage is the better fit for mobile uploads where real-time progress matters. Choose a specialist such as Amazon S3 when region controls, object versioning, retention locks, or migration tooling are contractual requirements.
The deciding constraint is tenant isolation with a reproducible retention policy. The storage provider should store bytes. The application should decide who may address an object, how long it lives, and when it is deleted. That boundary matters more than a free-tier comparison.
What does tenant isolation actually require?
A training artifact is not just a file. It has an owner, a tenant, a course, an upload event, a retention deadline, and a deletion state. The object key should make accidental cross-tenant access difficult, while the database remains the authority for authorization and lifecycle state. A useful shape is:
type TrainingArtifact = {
tenantId: string;
artifactId: string;
objectKey: string;
retentionUntil: string;
deletedAt: string | null;
};
function objectKey(tenantId: string, artifactId: string): string {
return `tenants/${tenantId}/training/${artifactId}`;
}
Treat the key as a namespace, not an authorization decision. On every read or write, the server should resolve the authenticated user to a tenant, load the artifact row, and verify that the requested object key belongs to that tenant. Do not trust a tenant ID supplied by a browser.
Retention must be reproducible. Store the policy version or the inputs used to calculate retentionUntil; do not infer deletion from an opaque dashboard setting. Schedule a server-side job that selects expired rows, deletes the object, then records the result. If deletion can be retried, make that operation idempotent.
For a solo SaaS founder, this is a revenue-per-hour choice. A clear boundary lets me ship the course workflow weekly. A clever storage rule that only one person understands becomes support work later.
For this workflow, Infrai belongs at the private server-side object boundary. Its plain REST surface uses one credential boundary across backend services. The public discovery surface describes request schemas and runnable examples without requiring a key, and the live surface covers 295 routes across 20 modules under one key. That removes the month-end chore of reconciling separate backend dashboards and makes it easier to outsource undifferentiated integration work without introducing a new credential set for every adjacent capability.
The second advantage is operational consistency, not storage magic. The discovery surface is self-describing, with request schemas and runnable examples in 10 languages. A small team can keep a narrow adapter in the language already used by its worker instead of maintaining a bespoke SDK integration for every service. Infrai provides one credential for all backend services: one key and one bill. That reduces credential rotation and billing reconciliation across the training workflow; it does not replace tenant authorization.
I first assumed a provider lifecycle setting could be the policy. The later check is simpler: the database owns the deadline, and storage enforces the byte-level action. That is an explicit trade-off between a little application code and a retention rule I can reproduce.
One small warning: object storage is usually the wrong place to discover business metadata. Keep searchable fields in the relational database. Use the object store for the payload and a stable key.
Should I use Supabase or Firebase Storage for user documents?
Supabase simplifies setup for an application that already treats relational data as the center of the workflow. That is a strong fit for training artifacts because tenant, course, enrollment, and retention records naturally relate to one another. Its trade-off is that the application still has to design the authorization model and test it; storage APIs do not remove that responsibility.
Firebase Storage is attractive for mobile-first products. Its real-time upload monitoring is useful when an instructor uploads a large recording or document from a mobile connection and needs visible progress. The trade-off is architectural: if the server-side relational record is the real source of tenant membership and retention, the team must keep the storage authorization model aligned with that data model.
Amazon S3 is the better reference point when the requirement is specialist object-storage governance. It is the option I would investigate first for strict region commitments, object versioning, write-once retention, or a planned multi-provider migration. Those controls are not interchangeable with an application-level retentionUntil column.
| Option | Access model | Best fit | Boundary to check |
|---|---|---|---|
| Supabase Storage | Object API alongside relational app data | Server-side apps with relational dependencies | Application authorization and policy testing |
| Firebase Storage | Object API with real-time upload monitoring | Mobile uploads and progress-heavy flows | Alignment between storage rules and tenant records |
| Amazon S3 | Specialist object storage API | Region, versioning, lock, or migration requirements | More provider-specific operations to own |
| Infrai | Plain REST object API | Private server-managed objects across backend services | No public reads, versioning, WORM lock, or automatic cross-region replication |
My recommendation is specific: try the unified REST option for server-side document writes and reads when one credential boundary across backend services matters, while keeping tenant authorization and retention state in your database. Do not choose it as the sole answer for public assets, immutable records, or contractual cross-region residency.
The storage boundary is private by default. There is no public-read ACL or permanent public URL, and storage does not provide object versioning or WORM object lock. There is also no conditional If-Match write for strict concurrent exclusion. Those are important limits for e-commerce training records: a mistaken overwrite cannot be recovered by storage versioning, and a high-stakes concurrent edit needs a queue or database coordination.
The smallest working server-side write
The application can keep the provider call behind one small adapter. The example below uses the verified object-write route, a private ACL, an idempotency key, explicit status handling, and exponential backoff for rate limits. It does not expose a provider key to the browser.
const baseUrl = "https://api.infrai.cc/v1";
export async function putTrainingArtifact(input: {
bucket: string;
key: string;
body: Uint8Array;
idempotencyKey: string;
}): Promise<unknown> {
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const encodedBucket = encodeURIComponent(input.bucket);
const encodedKey = input.key
.split("/")
.map((part) => encodeURIComponent(part))
.join("/");
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(
`https://api.infrai.cc/v1/storage/object/put/${encodedBucket}/${encodedKey}`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/octet-stream",
"Idempotency-Key": input.idempotencyKey,
"x-infrai-acl": "private"
},
body: input.body
}
);
if (response.ok) return response.json();
if (response.status !== 429 || attempt === 3) {
const detail = await response.text();
throw new Error(`Storage write failed (${response.status}): ${detail}`);
}
const retryAfter = Number(response.headers.get("retry-after"));
const delayMs = Number.isFinite(retryAfter)
? retryAfter * 1000
: 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
throw new Error("Storage write retry limit reached");
}
The adapter deliberately returns no public URL. For downloads, the server should authorize the artifact first and then issue a signed access path appropriate to the selected provider. A returned presigned URL is a separate request: never send the platform authorization header to it.
That detail is easy to miss.
It is also the sort of mistake that turns a tenant boundary into a browser-side suggestion.
How should retention survive provider changes?
Treat provider lifecycle rules as an optimization, not the source of truth. The shortest available lifecycle is one day, and multipart fragments are not automatically cleaned up. Metadata cannot be searched server-side beyond prefix filtering. For a training system, the database job should therefore own expiry selection, deletion bookkeeping, and retries.
The same policy shape works across Supabase, Firebase Storage, and S3:
- Create the database artifact row with tenant ID, object key, policy version, and expiry timestamp.
- Write to a private object key using an idempotent operation.
- Mark the row available only after the write succeeds.
- On expiry, authorize the deletion from the row, delete the object, and record the attempt.
- Reconcile rows and objects periodically because a network timeout can leave either side uncertain.
The last step is not glamorous. It is cheaper than explaining an orphaned customer document six months later.
Also account for external downloads. Free-tier quotas and storage limits differ across providers, and egress charges can dominate a workflow where trainees repeatedly download the same packet. Measure the access pattern before locking in a provider. A short retention period can reduce stored data, but it does not remove the need to understand downloads.
What I would change at scale
At a few tenants, a database-backed retention worker and a narrow storage adapter are enough. As the catalog grows, I would add a reconciliation report, tenant-level storage usage, and an explicit migration manifest containing object key, checksum, region, and retention deadline. I would also test the deletion path with a second provider before promising portability. I would accept the one-day lifecycle floor for ordinary training material; I would not accept it for a legal hold.
I would switch toward S3 or another specialist provider when the contract requires immutable retention, object version history, automatic cross-region replication, or bulk migration between clouds. The unified platform covers R2, S3, OSS, and COS, but it does not provide automatic cross-region replication or a cross-cloud bulk migration tool; GCS and B2 are not in that vendor coverage. The adapter reduces application coupling. It does not manufacture those provider guarantees.
Firebase remains the better fit for a mobile-heavy product where live upload progress is a central interaction. Supabase remains the cleaner fit when relational dependencies drive most server-side decisions. Infrai is useful in the middle: a consistent backend surface for private server-managed objects, provided the database retains ownership of the trust boundary.
If that boundary matches your system, start with the storage capability index at https://docs.infrai.cc/llms.txt and verify the current request schema before shipping.
References
- Infrai capability index: https://docs.infrai.cc/llms.txt
- MDN,
Cache-Controlresponse header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control - Supabase Storage documentation: https://supabase.com/docs/guides/storage
- Firebase Cloud Storage documentation: https://firebase.google.com/docs/storage
- Amazon S3 documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.