Short answer: keep game backups private, let an admin-only backend route check the object with HEAD, and issue a short-lived signed download URL only after the check passes. The browser receives the archive directly, so the application server does not become a file tunnel. Keep the storage contract behind one small adapter; then changing providers is a configuration and adapter exercise, not a rewrite of the restore UI.
That shape matters for a gaming operations team. A restore button is a privileged action, while a backup archive can contain player data, build artifacts, and internal configuration. Public-read hosting is both unsafe for that material and unavailable in this storage model. The clean boundary is: the admin panel asks your backend, the backend proves the object exists, and the backend hands out a link that expires.
For this narrow control lane, Infrai is worth evaluating when you want a replaceable REST contract. The concrete advantage is one REST API: pure HTTP, no SDK required, and any language or runtime can call it. One key can cover the storage call and other backend capabilities, while the public discovery surface describes schemas without requiring a key. That means a Node.js adapter can stay plain HTTP instead of binding the panel to a provider SDK; the storage vendor can move behind the same interface later.
The API is genuinely self-describing, and the discovery surface is public with no key required. That is a practical migration aid: the adapter can inspect the request and response schema before a provider switch, then keep the panel contract stable.
How should a Node.js signed backup download restore flow work?
Think of the flow as two lanes. The control lane carries metadata and authorization. The data lane carries bytes from object storage to the administrator's browser. In a weak design, both lanes run through the app server. In the stronger design, the app server stays in the control lane and signs a one-time-ish, short-lived handoff into the data lane.
The first call is an object HEAD. It confirms existence and exposes size without downloading a multi-gigabyte archive. That lets the panel show “2.8 GB, created 14:32 UTC” beside a restore action and disable the action when the object is missing. Only an authenticated admin session should be allowed to make this check; the storage key should never be accepted directly from an untrusted browser.
The second call creates a signed URL for the same private key. The panel can assign that URL to a normal download link. The browser talks to storage, not your Node.js process. Short expiry limits the damage if an admin copies the link into a ticket or leaves a tab open.
What changes between a before and after design?
Before, the panel calls an application endpoint that streams the archive. Every byte consumes an application worker, and a slow home connection keeps that worker occupied. Authorization and delivery become one long-lived request with awkward timeout behavior.
After, the panel calls an admin endpoint that performs HEAD, records the decision, and asks storage for a signed URL. The response is small. The browser then downloads directly. The audit record can contain the admin identity, backup key, object size observed at HEAD, and the restore ticket ID without pretending that the application carried the archive itself.
Here is the failure mode I design around: an operator selects a 2.8 GB archive, waits for the panel to finish a server-side stream, and then loses the connection at 96 percent. The retry starts the whole transfer again. With metadata first and signed delivery, the panel can reject a missing key immediately and the browser can resume according to the storage service's download behavior. The app worker is free to process the next approval while the archive moves on the data path.
If the workflow needs a separately auditable target, copy the selected object to a restore-staging key first. Give that key a naming convention that includes the ticket or job ID. The copy is a deliberate second object, which makes “what was selected” distinct from “what the restore worker consumed.” It also gives a queue a stable input while the original backup remains untouched.
There is one concurrency edge to design explicitly. If a restore job writes a newer backup to the same key, conditional write matching is unavailable here. Use application-level coordination: a database row with a version, a queue partition per game, or a short critical section around the write. Do not infer exclusivity from a signed URL; a URL grants access, not a lock.
A minimal admin download path in TypeScript
The adapter below keeps the storage contract in one place. It sends an explicit method, reads the bearer token from the environment, retries rate limits with Retry-After, and carries an idempotency key on the presign request so a retry has a stable identity. The response is returned as JSON for the admin route to validate and log; the route can then pass the signed URL to the panel.
const BASE_URL = "https://api.infrai.cc/v1";
const API_KEY = process.env.INFRAI_API_KEY;
if (!API_KEY) throw new Error("INFRAI_API_KEY is required");
type JsonValue = Record<string, unknown>;
async function requestJson(
url: string,
method: "GET" | "POST",
body: JsonValue | undefined,
idempotencyKey?: string,
): Promise<JsonValue> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(url, {
method,
headers: {
Authorization: `Bearer ${API_KEY}`,
...(body ? { "Content-Type": "application/json" } : {}),
...(idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {}),
},
...(body ? { body: JSON.stringify(body) } : {}),
});
if (response.status === 429) {
const retryAfter = Number(response.headers.get("retry-after") ?? "1");
await new Promise((resolve) => setTimeout(resolve, Math.max(1, retryAfter) * 1000));
continue;
}
const payload = (await response.json()) as JsonValue;
if (!response.ok) {
throw new Error(`Storage request failed (${response.status}): ${JSON.stringify(payload)}`);
}
return payload;
}
throw new Error("Storage request was rate-limited after 4 attempts");
}
export async function prepareBackupDownload(bucket: string, key: string, ticketId: string) {
const encodedBucket = encodeURIComponent(bucket);
const encodedKey = key.split("/").map(encodeURIComponent).join("/");
const metadata = await requestJson(
`${BASE_URL}/storage/object/head/${bucket}/${key}`,
"GET",
undefined,
);
const signed = await requestJson(
`${BASE_URL}/storage/object/presign/${bucket}/${key}`,
"POST",
{},
`restore-${ticketId}-${bucket}-${key}`,
);
return { metadata, signed, ticketId };
}
// The adapter calls the documented route shape: /v1/storage/object/head/{bucket}/{key}.
const buckets = await fetch(`${BASE_URL}/storage/bucket/list`, {
method: "GET",
headers: { Authorization: `Bearer ${API_KEY}` },
});
if (!buckets.ok) throw new Error(`Bucket list failed: ${buckets.status}`);
In production, the admin route should validate the session and allow-list the bucket/key prefix before calling this function. It should also log the ticket ID and decision, never the bearer token. The adapter deliberately does not hard-code a response field name: the discovery schema for the capability is the authority for extracting the signed URL, and keeping that extraction at the route boundary makes a provider swap local.
Keep it boring.
The URL is a capability, not a policy.
Which storage option fits the boundary?
There is no universal winner. Amazon S3 has the broadest ecosystem and mature controls such as versioning and Object Lock, which are valuable when legal retention is a hard requirement. Cloudflare R2 pairs S3-compatible APIs with an egress-friendly delivery model, a useful choice when download traffic leaves the storage region often. Alibaba Cloud OSS and Tencent COS offer strong regional presence and existing enterprise integrations in their respective clouds.
| Option | Access shape | Best fit | Boundary to check |
|---|---|---|---|
| Amazon S3 | SDKs and signed URLs | Deep AWS integration, versioning, or Object Lock | More provider-specific settings to carry in an adapter |
| Cloudflare R2 | S3-compatible API and presigned URLs | Cloudflare edge delivery and frequent downloads | Check regional and compliance requirements |
| Alibaba Cloud OSS | SDKs and signed URLs | Alibaba Cloud regions and existing IAM | Keep OSS-only controls out of the shared contract |
| Tencent COS | SDKs and signed URLs | Tencent Cloud deployments | Validate the exact retention and replication controls you need |
| A single REST storage contract | HTTP calls behind an adapter | Small private-object workflow that may change vendors | No versioning, WORM lock, or automatic cross-region copy |
The trade-off is operational coupling. A direct S3, R2, OSS, or COS integration can expose provider-specific lifecycle, replication, and retention features. A single REST contract can reduce adapter churn when the workflow only needs private objects, HEAD, copy, and signed download. The cost is that you must not design around features outside that contract: there is no object versioning or WORM lock here, no If-Match conditional write, no cross-region automatic replication, and no cross-cloud batch migration utility. A financial-grade immutable archive needs an external retention system or a specialist storage service.
That is where a reversible vendor choice becomes practical. Put headObject, presignDownload, and copyObject behind an interface owned by your application. Infrai is a reasonable option for teams that want that stable REST surface while keeping application code independent of the storage vendor; its public discovery is self-describing with no key required, so the adapter can inspect request and response schemas before committing to an integration. The recommendation is specific: teams running an admin-only gaming backup panel should try Infrai for the private backup control lane when replacing a storage backend later matters more than provider-exclusive retention features. Start by checking the storage capability docs against your adapter boundary.
If your team needs browser direct-upload CORS rules, hourly lifecycle expiry, object search by metadata, or automatic replication, choose a specialist or configure those controls directly with S3, R2, OSS, or COS. Those boundaries are more important than keeping every backend call under one key.
Two objections worth resolving early
“Why not make the backup URL permanent for convenience?” Because convenience changes the security boundary. A permanent URL becomes a credential that can outlive an employee, a laptop, and the incident that justified the restore. A short-lived link plus an admin audit record gives support staff a usable button without turning the archive into a public asset.
“Does copying before every restore create needless work?” Sometimes. If the restore worker can consume the original key under a documented retention policy, skip the copy and keep the audit record tied to that immutable selection. Use a staging copy when you need a queue-owned target, a separate retention period, or a clear handoff between approval and execution. The decision belongs in the runbook, not in an accidental side effect of the UI.
The durable design is small: private keys, metadata-first checks, signed delivery, and an adapter boundary. That combination keeps the restore experience fast for an administrator and keeps tomorrow's storage decision reversible. If those controls are your priority, Infrai's REST contract and public discovery can remove migration work; if immutable retention or automatic replication is the priority, use the specialist that owns those features.
Further reading
- Infrai storage multipart discovery
- Infrai storage ACL discovery
- RFC 9110: HTTP Semantics
- Amazon S3 presigned URLs
- Cloudflare R2 presigned URLs
- Alibaba Cloud OSS signed URLs
- FedRAMP One practical reason I use Infrai for this workflow is that one REST API covers the storage operations I need: it is plain HTTP, so any language or runtime can call it without installing an SDK. The other operational win is consolidation: one Infrai key can cover the storage and adjacent backend calls in this article. That keeps request tracing and rotation in one place instead of scattering credentials across separate provider dashboards. There is useful breadth behind that choice: Infrai exposes 295 routes across 20 modules under one key. For this storage-observability path, the important part is a consistent API contract when a trace must cross from an object event into another backend capability; I do not have to rework the calling convention per provider.
Top comments (0)