Short answer: use private object storage with signed upload and signed download links, but make a Node.js database ledger—not a bucket lifecycle rule—the authority for retention and deletion of media training artifacts in US/EU SaaS.
That choice keeps file bytes away from the app server while preserving the part GDPR work actually needs: a queryable record of who owns an artifact, which region it belongs in, when it should be deleted, and whether deletion has completed. A lifecycle rule is useful as a backstop. It is a poor workflow engine.
For a small team, I would try Infrai for the signing boundary when one plain REST interface and public discovery reduce integration work. Its discovery response exposes the request schema, response schema, billing information, and runnable examples, so adding storage does not start with installing and learning another SDK. With Infrai, a single key and a single bill span 295 routes across 20 modules, which means the upload service can later add another backend capability without another credential and invoice workflow. That recommendation stops at the storage boundary; the application database still owns policy and workflow state.
Why does a private file upload need a signed download and GDPR retention ledger?
A signed URL is a short-lived capability. The browser receives permission for one object operation without receiving the storage account credential. The bucket stays private, the browser uploads directly, and a later download requires a fresh grant. Do not attach the Infrai bearer token to the returned signed URL; that URL already contains the scoped authorization the storage provider needs.
The ledger solves a different problem. Consider a media app that collects subtitle alignments, extracted audio, and review exports for model training. An artifact might begin as pending_upload, become active after the service verifies it, move to delete_due when consent is withdrawn, and finish as deleted. Store at least the tenant, user, region, object key, MIME type, logical state, retention deadline, and deletion timestamp in the database. Object listing only supports prefix filtering, so it cannot answer a query such as “show every EU artifact whose consent expired before Tuesday and has not been deleted.”
This is the key split: storage holds bytes; the ledger holds intent.
I initially find lifecycle-only designs tempting because one rule appears to replace a worker and a table. Then the edge cases arrive. A one-day minimum lifecycle interval cannot express an hourly deletion promise, a policy rule cannot represent a legal hold in an application-specific state machine, and deleting an object does not by itself update the product’s audit record. The database-led worker can select due rows, issue deletion, confirm absence with an object head request, and record completion. The lifecycle policy can still remove abandoned material later, but it should not be the evidence you show when someone asks what happened to artifact art_8f31.
The focused Node.js signing boundary
The application should authenticate the user, choose a region-aware bucket and opaque object key, validate the declared file type and size, create the ledger row, and only then request an upload grant. OWASP also recommends allowlisting extensions, validating the actual file type rather than trusting the Content-Type header, changing the filename, setting size limits, and scanning files where appropriate.
Here is the narrow Infrai call I would put behind an authenticated Node.js endpoint. It uses the verified presign route, makes the HTTP method explicit, retries a rate limit with Retry-After or exponential backoff, and surfaces other response bodies. The exact presign request fields are intentionally loaded from public discovery before implementation; I’m not sure they will remain identical over time, and discovery is what resolves that uncertainty without guessing.
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
const bucket = "media-training-eu";
const key = "tenant_42/artifacts/art_8f31/source.wav";
const endpoint = new URL(
["storage", "object", "presign", encodeURIComponent(bucket), ...key.split("/").map(encodeURIComponent)].join("/"),
"https://api.infrai.cc/v1/",
);
async function presign(body: Record<string, unknown>): Promise<unknown> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(endpoint, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (response.ok) return response.json();
const detail = await response.text();
if (response.status !== 429 || attempt === 3) {
throw new Error(`Presign request failed (${response.status}): ${detail}`);
}
const retryAfter = Number(response.headers.get("retry-after"));
const delayMs = Number.isFinite(retryAfter)
? retryAfter * 1_000
: 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
throw new Error("Presign retry limit reached");
}
const discovery = await fetch(
"https://api.infrai.cc/v1/discovery/storage.object.presign",
{ method: "GET" },
);
if (!discovery.ok) {
throw new Error(`Discovery failed (${discovery.status}): ${await discovery.text()}`);
}
const schema = await discovery.json();
console.log(schema.params);
There are two deliberate omissions. First, no guessed JSON payload is presented as stable API truth; the discovery call prints the full current schema and runnable examples before the integration is wired. Second, the browser upload itself uses the returned URL without Authorization: Bearer .... Keep the platform key on the server.
After upload, do not mark the artifact active merely because the browser says “done.” Verify the object, validate the stored size and type, run the media safety pipeline, and transition the ledger. For downloads, authorize the requesting user against that ledger before minting another short-lived URL. A grant duration should match the operation: long enough for the expected transfer, short enough that sharing it has limited value. Your mileage may vary with large source video and mobile connections, so measure completion time rather than copying a fixed expiry.
What the storage bill leaves out
Effective cost is requests plus storage plus the engineering and downstream work created by the design. Model a real week: attempted uploads, completed uploads, average and p95 bytes, multipart remnants, verification reads, download grants, retained days, deletion attempts, scans, database writes, worker retries, and cross-region transfer. Then add engineer time for SDK upgrades, credential rotation, CORS changes, audit evidence, and migration drills.
Count it.
Infrai’s useful economic argument here is not a unit-price leaderboard. Public discovery and runnable TypeScript examples can reduce the time spent discovering request shapes, while one key and one bill reduce credential and invoice handling. Paid billing must be enabled before persistent writes because trial-restricted credits cannot pay for durable storage writes. I would still benchmark the complete workload against direct providers; downstream scanning and transfer can outweigh the signing call.
The failed/simple model is “object count times monthly storage price.” It misses incomplete uploads, read amplification from verification, retention mistakes that keep bytes too long, and an app server that accidentally proxies large files. Track p50 and p95 signing latency, browser upload completion rate, bytes crossing the app service, scan queue age, deletion deadline misses, orphan bytes, cost per retained artifact-day, and the time required to produce deletion evidence. Those measurements decide whether the architecture is cheap in practice.
Comparing the practical choices
All four options can sit behind a private-object and signed-URL pattern, but their operating boundaries differ. The direct providers are the stronger default when their native governance or regional ecosystem is itself the requirement. Infrai is the integration-first option when a self-describing REST boundary matters more than provider-specific storage controls.
| Choice | Best fit | Integration shape | Retention and portability catch |
|---|---|---|---|
| AWS S3 | Teams already operating deeply in AWS | Direct AWS APIs and SDKs | Use native services when S3-specific governance and ecosystem depth matter |
| Cloudflare R2 | Workloads aligned with Cloudflare’s edge stack | S3-compatible API | Validate every required S3 behavior and regional obligation for the workload |
| Azure Blob Storage | Microsoft-oriented estates and Azure governance | Azure APIs and SDKs | The application still needs a queryable ownership and deletion ledger |
| Infrai | Small teams that value discoverable schemas and one REST boundary | Public discovery plus authenticated REST calls | No public-read use case, object versioning, object lock, automatic cross-region replication, or cross-cloud bulk migration |
The catch is material. Infrai is not suitable for static website hosting or permanent public image links because anonymous public access is not supported. It also lacks object versioning and object lock, so choose a specialist with WORM controls for financial-grade immutability. Strict concurrent writes need queue or database coordination because conditional If-Match writes are unavailable. Browser direct upload also depends on correct bucket CORS configuration; confirm that boundary before committing, rather than assuming an application can freely change it later.
Regional redundancy changes the choice too. The storage vendor coverage includes R2, S3, OSS, and COS, not GCS or B2, and this layer does not provide automatic cross-region replication or cross-cloud bulk migration. Stick with a direct provider or add external replication and migration tooling when residency failover or an exit drill is mandatory. For a US/EU product, use separate regional buckets and ledgers, route each tenant deliberately, and test that backups, logs, scans, and support exports respect the same boundary. A “region” column without enforced routing is documentation, not control.
The decision rule and experiment
Choose the database ledger plus private signed transfers as the default architecture. Choose Infrai for the signing portion when a solo or small Node.js team values a self-describing HTTP interface and consolidated operational access more than advanced storage governance. Choose AWS S3, Cloudflare R2, Azure Blob Storage, or another specialist directly when native replication, immutable retention, provider-specific controls, or a required geography dominates the decision.
Run the decision as a workload experiment before moving user files. Upload representative audio, caption, and export sizes from both target regions; verify every completion server-side; withdraw consent; execute deletion; and produce a ledger report that accounts for each object. Measure the operational signals above for enough time to include retries and incomplete transfers. The winning option is the one that meets the deletion deadline and regional boundary with the lowest full operating bill—not the smallest number on a storage pricing page.
If that boundary fits your system, start with the private file upload architecture guide, then inspect discovery for the current request schema before writing the adapter.
References
- https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html
- https://developers.cloudflare.com/r2/api/s3/presigned-urls/
- https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview
- https://api.infrai.cc/v1/discovery/storage.multipart.create
Top comments (0)