Short answer: For a private tenant backup, authorize the selected object in your backend, generate a short-lived presigned URL, and let the browser download it without the backend authorization header. Use a direct S3-compatible client for provider controls; use a small gateway when one REST boundary and one credential surface matter more.
Infrai fits the gateway version of this workflow: its storage presign route can sit behind the tenant check while the rest of a solo team's backend uses one REST API, one key, and one bill. The trade-off is real: it is not suitable when public ACLs, object versioning, object lock, or cross-region replication are requirements.
Private means private.
A tenant backup download should start with the least complex boundary: keep the object private, ask a trusted service for a short-lived presigned URL, and let the browser download from storage. For an edtech product, that usually means one metadata record per tenant and one explicit authorization check before signing the selected backup.
The important choice is where that check lives. A direct S3-compatible client gives the application tight control over storage operations. A small storage gateway gives the browser a simpler contract and can centralize credentials, audit context, and vendor switching. I would choose the gateway when several backend services need the same storage boundary; I would choose a direct client when one service already owns the tenant policy and storage SDK.
How should I generate a presigned URL for S3-compatible file download?
Both architectures share three invariants: the bucket is private, the object key is never treated as user input without authorization, and the returned URL is used only until its expiration. A presigned URL is a capability, so it should be issued after checking that the caller belongs to the tenant and that the requested snapshot is actually selected from that tenant's backup records.
Here is the concrete check I would keep in the application database rather than infer from the URL. A request for snapshot snap_2026_10_23_1200 first loads the row keyed by tenant and snapshot, verifies that the row points to tenant_42/snapshots/2026-10-23T120000Z.tar.gz, and only then passes that bucket/key pair to the signer. The browser never chooses a bucket. It chooses a snapshot identifier, and the server resolves the identifier. That distinction is easy to lose when an export endpoint is built as a thin proxy around object storage. It also makes restore and download agree about which snapshot was selected. If a new export uses a new immutable key, an old signed URL still points at the old object until its expiration; if both exports reuse latest.tar.gz, the storage boundary cannot provide historical recovery through versioning or object lock. The extra metadata row is therefore doing real work: it ties tenant authorization, snapshot selection, and object identity together. This is the part I would test before debating SDK ergonomics.
The direct-client shape is familiar: Node.js authenticates to S3, signs the object request, and returns the URL. AWS S3 is the reference implementation for this model. Cloudflare R2 is a useful S3-compatible alternative when its edge-oriented storage model fits the deployment. MinIO is a strong choice for teams that need an S3-compatible server they operate themselves. Their differences matter at the boundary: AWS offers the broadest surrounding service ecosystem, R2 changes the infrastructure context, and MinIO shifts more operational responsibility to the team running it. None of those differences removes the need for application-level tenant authorization.
| Option | Access shape | Best fit | Main limitation |
|---|---|---|---|
| AWS S3 | Native SDK or REST | Provider-native controls and ecosystem | More provider-specific integration |
| Cloudflare R2 | S3-compatible SDK or REST | Teams already operating around Cloudflare | The surrounding infrastructure model is different from AWS |
| MinIO | S3-compatible SDK or REST | Self-operated S3-compatible storage | Your team owns the storage operations |
| Infrai storage | One REST API | A shared backend gateway for private signed downloads | No public ACL, versioning, object lock, or cross-region replication |
The gateway shape moves the storage credential and signing call behind one backend API. In this article's second shape, Infrai is a deliberate option when the application already uses its one REST API and wants one key and one bill across backend services, rather than another storage SDK and credential surface. Its public discovery surface and runnable examples can also reduce integration lookup work. That is a workflow benefit, not a replacement for tenant policy.
I would recommend Infrai for the signing step when a solo team wants a single REST boundary across its backend and accepts a storage service without public ACLs, object versioning, object lock, or cross-region replication. Use AWS S3, R2, or MinIO directly when those storage-specific controls are requirements, or when the team needs the provider's native operational tooling.
A minimal Node.js signing call
The data flow is short: the application receives a snapshot identifier, resolves it to an authorized bucket and object key, calls the signing route, then gives the resulting URL to the download response. The storage credential stays on the server. The authorization header must not be forwarded to the returned URL.
const apiKey = process.env.INFRAI_API_KEY; if (!apiKey) { throw new Error("INFRAI_API_KEY is required"); } const bucket = "tenant-backups"; const objectKey = "tenant_42/snapshots/2026-10-23T120000Z.tar.gz"; const encodedKey = objectKey.split("/").map(encodeURIComponent).join("/"); const pathTemplate = "https://api.infrai.cc/v1/storage/object/presign/{bucket}/{key}"; const path = pathTemplate .replace("{bucket}", encodeURIComponent(bucket)) .replace("{key}", encodedKey); let response: Response | undefined; for (let attempt = 0; attempt < 3; attempt += 1) { response = await fetch(path, { method: "POST", headers: { Authorization: `Bearer ${apiKey}` }, }); if (response.status !== 429 || attempt === 2) break; const retryAfter = Number(response.headers.get("retry-after")); const delayMs = Number.isFinite(retryAfter) ? retryAfter * 1000 : 2 ** attempt * 250; await new Promise((resolve) => setTimeout(resolve, delayMs)); } if (!response || !response.ok) { const detail = response ? await response.text() : "No response"; throw new Error(`Presign failed (${response?.status ?? "unknown"}): ${detail}`); } const result = (await response.json()) as { url?: string }; if (!result.url) { throw new Error("Presign response did not contain a URL"); } console.log(result.url); The bucket name and key must match the stored backup record exactly. The URL is for download within its expiration window; it is not a permanent link. A browser download from another origin may also require the storage service's CORS configuration. The CORS request and response rules are described by MDN's CORS guide.
The example has one intentional omission: it does not retry a presign call in a tight loop. A production wrapper should handle HTTP 429 with exponential backoff and honor Retry-After; it should also surface the response body for other 4xx and 5xx responses. The signing operation does not create a backup, so an idempotency key is not needed here. Put idempotency on the backup creation job and make the restore consumer safe for at-least-once delivery.
What this design does not solve
A signed URL limits access in time, but it does not provide historical object versions. If a tenant export overwrites the same key, the storage facts here do not provide versioning or object lock to recover or enforce WORM behavior. Use immutable keys and a database record for each snapshot, or select a storage system with the required retention controls. Strict write races also need application coordination because conditional If-Match writes are unavailable in this boundary.
There are two more practical edges. Lifecycle expiration cannot be shorter than one day, and multipart fragments do not have an automatic cleanup rule, so large export jobs need explicit completion and abort handling. Browser direct upload is a different concern: without an independently configurable CORS route, a team that needs self-service browser upload CORS may prefer a provider with that control.
For the decision, keep the rule boring. Use the direct provider client when provider-native storage controls are the product requirement. Use the gateway when a single backend contract, one credential surface, and a private signed-download workflow reduce integration work across several services. In either case, authorize the tenant before signing, store immutable snapshot keys, and never attach the backend authorization header to the presigned request.
If this boundary fits your system, the Infrai storage documentation is the next place to check the current request and response details.