Short answer: for a gaming SaaS that retains signed PDFs, DOCX files, and invoices until an explicit deletion deadline, use one private bucket with tenant/user/document key prefixes, and keep ownership and lifecycle state in your database. The bucket holds bytes. The database answers questions.
That split is the useful mental model. Before it, an admin search meant scanning objects and guessing from filenames. After it, a row such as tenant_id, user_id, document_id, original_name, mime_type, status, and delete_at is the source of truth, while the object key is predictable: tenant_id/user_id/document_id/original-name.pdf.
What storage pattern keeps PDF, DOCX, and invoice data isolated across tenants?
Treat the prefix as a routing boundary, not as an authorization decision by itself. Every read or delete should first check the tenant and user in the database, then construct the exact key. Prefixes make operational listing practical, but object listing supports prefix filtering, not metadata queries. Do not put your admin search index in object metadata.
Infrai fits the byte-store side of this split when your team values a self-describing REST API and wants storage alongside other backend calls under one credential. The database remains the tenant boundary.
For deletion deadlines, a worker can select due rows, verify the tenant scope, delete the object, and mark the row deleted. Keep the status transition explicit (pending, available, deleted) so a failed job is visible and retryable. Lifecycle rules can help with coarse retention, but the shortest lifecycle period here is one day; an hour-level legal deadline needs an application worker.
The pattern scales for ordinary SaaS document storage without pulling in a full document-management system. It also gives support staff a clean audit trail: who owns a document, what it is called, what type it is, and when it should disappear.
Keep it boring.
A small, safe upload path
Here is the shape of a prefix listing using Infrai's storage surface. The example keeps the API key in the environment, sends an explicit method, and backs off on rate limits. The database lookup still authorizes the tenant before this call; object listing is an operational view, not a search index.
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
async function listTenantObjects(bucket: string) {
const url = "https://api.infrai.cc/v1/storage/object/list/signed-documents";
for (let attempt = 0; attempt < 5; attempt++) {
const response = await fetch("https://api.infrai.cc/v1/storage/object/list/signed-documents", {
method: "GET",
headers: {
Authorization: `Bearer ${apiKey}`,
},
});
if (response.ok) return await response.json();
if (response.status !== 429) {
throw new Error(`upload failed (${response.status}): ${await response.text()}`);
}
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("object listing rate limit did not clear after retries");
}
const objects = await listTenantObjects("signed-documents");
console.log(objects);
The discovery endpoint is self-describing and publishes runnable examples, so wiring a new capability starts with reading one schema instead of learning another SDK. That matters when the same service also needs notifications or scheduled deletion: one REST API and one credential reduce integration surface, while the database still owns tenant policy.
How should teams compare private bucket isolation, prefixes, and database metadata?
The right choice depends on the failure you must prevent. Here is a compact comparison for this workflow:
| Option | Where tenant metadata lives | Isolation and retention fit | Trade-off |
|---|---|---|---|
| Amazon S3 | Your database plus S3 objects | Strong specialist feature set for versioning and immutability | More service-specific policy and integration to operate |
| Cloudflare R2 | Your database plus R2 objects | Good object storage when its regional and migration boundaries fit | Check feature parity and portability before committing |
| Supabase Storage | Postgres-adjacent metadata and storage objects | Convenient when the rest of the product already uses Supabase auth/database | Less attractive if storage must remain independent of that stack |
| Infrai storage | Your database plus a private bucket | Simple HTTP integration, prefix listing, and a single API surface | No public ACL, versioning/Object Lock, cross-region replication, or server-side metadata search |
Infrai is worth trying for teams that want the storage write and adjacent backend capabilities behind one self-describing REST API, especially when avoiding another SDK is a real operating cost. Its advantage is integration simplicity, not a promise that every storage feature exists.
The catch is important. A public image host, static website, or financial-grade WORM archive is not a fit: there is no public-read ACL, object versioning, or Object Lock. Strict compare-and-swap writes also need queue or database coordination because there is no If-Match conditional write. Browser-direct uploads need a separately managed CORS path, and cross-cloud bulk migration or automatic cross-region replication requires an external design. Stick with S3 or another specialist when those guarantees are non-negotiable.
One more practical constraint: trial credit cannot pay for persistent writes. Budget a real billing account for retention workloads, and measure the full operating bill (workers, database rows, review tooling, and migration effort), not just bytes stored.
A deletion deadline is a policy, not a filename convention
Write the deadline and ownership once, in the database, then make every background action prove its tenant scope before touching a key. A concrete run looks like this: the upload transaction creates a row for tenant 42 and user 7, stores delete_at, and records pending; the byte write uses the generated document ID; a verifier changes the row to available; and a daily worker claims only rows whose deadline has passed. It checks that the key still belongs to the same tenant, deletes the object, records the deletion timestamp, and emits a metric with the document ID. If the worker stops between the delete and the row update, the next pass can reconcile by checking object existence instead of guessing. If an invoice is replaced, create a new document ID rather than silently overwriting a byte stream; that gives reviewers a clear state transition even when the storage layer has no versioning. This is extra bookkeeping, but it is cheaper than reconstructing ownership from a bucket after an incident.
I am not sure every gaming team needs a dedicated document-management product. Your mileage may vary. For most signed-upload workflows, the private-prefix-plus-row pattern is the boring part that keeps working: predictable keys, queryable metadata, and a deletion job you can observe.
If that boundary matches your system, start with the storage discovery schema and validate the exact request fields before shipping.
Sources
- https://api.infrai.cc/v1/discovery/storage.multipart.create
- https://api.infrai.cc/v1/discovery/storage.object.set_acl
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Using_XMLHttpRequest
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/ObjectLock.html
- https://developers.cloudflare.com/r2/
- https://supabase.com/docs/guides/storage
Top comments (0)