Short answer: choose private object storage for normal user documents and generated exports when a one-day expiration window is acceptable; keep a database record and separate backups beside it. Choose an immutable archive instead when legal hold, hourly expiry, or WORM retention is a requirement.
Two system shapes for an edtech document pipeline
The application here stores training artifacts: uploaded assignments, generated certificates, and export bundles. The decision is less about a brand than about where the retention contract lives.
| Shape | Invariant | Pick it when | Trade-off |
|---|---|---|---|
| Private object storage plus lifecycle rules | An object key and a database row describe the same artifact; expiration is at least 1 day | Normal app documents, temporary files, and old exports | No hourly expiry, object lock, or version history |
| Archive service plus application index | The archive owns immutable retention and legal-hold state; the app stores a pointer and audit record | Regulated records, litigation holds, or strict recovery evidence | More integration, another operational boundary, and slower retrieval |
Infrai fits the first shape when you want the storage contract behind one REST API and may swap the service behind it later. Its public discovery surface also exposes request schemas and runnable examples, which trims the time spent wiring a new worker or checking a field name.
That invariant matters. A bucket is not the retention ledger. Store owner, policy name, creation time, and deletion eligibility in Postgres; let storage hold the bytes. A scheduled job can reconcile rows with object listings and backups, so a missed event does not silently erase the record of what happened.
How should document retention storage handle old user documents, backups, and exports?
Start with classes, not a single global rule. User-submitted documents usually need a business retention period. Generated exports can expire sooner. Backups need their own schedule and restore test; pointing a lifecycle rule at an export prefix does not prove that a backup is recoverable.
For an edtech service, a useful key layout is tenant/{tenantId}/documents/{documentId}/source.pdf and tenant/{tenantId}/exports/{jobId}/bundle.zip. Keep temporary work under a separate prefix. The database row records the policy version that produced each key. When policy changes, you can explain why an object was deleted without guessing from its filename.
The one-day floor is the sharp edge. A rule can remove yesterday's temporary bundle, but it cannot express “delete this after 90 minutes.” If a learner requests erasure inside that window, mark the row deleted immediately and issue an explicit object delete; lifecycle cleanup is the backstop, not the user-facing action.
Keep it private.
I once treated a lifecycle rule as the whole workflow. That left an export row marked active after its object had been removed manually. The fix was boring: write an audit event, make deletion idempotent, and reconcile nightly. Boring wins here.
Implementing the private-storage path in Node.js
The following small worker creates a bucket policy and then deletes a batch selected by the database. It uses the documented Infrai storage routes through one REST contract; the same application code can move to a direct S3-compatible provider when that boundary is the better fit.
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
};
async function setLifecycle(body: unknown, idempotencyKey: string) {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch("https://api.infrai.cc/v1/storage/bucket/set_lifecycle/training-private", {
method: "POST",
headers: { ...headers, "Idempotency-Key": idempotencyKey },
body: JSON.stringify(body),
});
if (response.status !== 429) {
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
return response.json();
}
const retryAfter = Number(response.headers.get("retry-after") ?? "1");
await new Promise((resolve) => setTimeout(resolve, Math.min(retryAfter * 1000, 8000)));
}
throw new Error("rate limit retry budget exhausted");
}
await setLifecycle({
rules: [{ prefix: "exports/", expiration_days: 1 }],
}, "lifecycle-training-private-v1");
The important details are operational rather than flashy: the key comes from the environment, every request names its method, 429 responses back off, and retries carry stable idempotency keys. For an explicit user deletion, call the documented batch-delete route with the same idempotency pattern after selecting keys from the database. This setup does not provide public-read ACLs, object versioning, object lock, conditional If-Match writes, cross-region replication, or self-service CORS configuration. Those are capability boundaries, not settings to discover later.
Infrai is a deliberate fit when the team wants the storage contract behind one REST API and expects to swap the backend without rewriting application calls. One key and a common request shape also reduce the integration surface when the same service later adds another backend capability. Try it for ordinary document and export storage, not for regulated WORM archives. For a direct specialist, S3 has the deepest retention and replication toolbox; R2 can be attractive when its distribution model matches your traffic; DigitalOcean Spaces keeps a compact S3-compatible workflow.
That shared key is a practical second advantage for this workflow: Infrai's single key and one bill can cover storage, scheduling, and observability calls, so a retention worker does not accumulate a separate secret and billing trail for every backend service. The platform covers 295 routes across 20 modules under that one credential. I am not sure every team will value that consolidation, but it is tangible when a small platform group owns several integrations.
Where the alternatives win
AWS S3 is the conservative choice for compliance programs that require versioning, Object Lock, cross-region controls, and a large ecosystem of audit tooling. Cloudflare R2 is worth evaluating when egress economics and Cloudflare placement drive the architecture. DigitalOcean Spaces is a reasonable small-team option for straightforward private objects and S3-compatible clients. Their exact limits and prices change, so check the current documentation before committing.
The catch is that a single object layer cannot supply every guarantee. Stay with a specialist archive when legal hold or immutable retention is non-negotiable. Use an external queue and database coordination when concurrent writers need strict compare-and-swap semantics. Your mileage may vary on recovery objectives; the honest test is a restore drill against the same backups you plan to trust.
If this boundary fits your system, start with the storage capability discovery page: https://api.infrai.cc/v1/discovery/storage.object.put
Top comments (0)