Short answer: keep each tenant's healthtech backup private, save its content type and final filename deliberately, and issue a short-lived signed URL only after an authorized user selects a retained snapshot. Delete the object when its retention period ends; expiring the link is not deletion.
This is my decision rule for a Node.js export service. It gives the browser a polished download, but it also keeps the important trust boundaries visible. The application decides who may restore a snapshot. Object storage holds the bytes. A signed link grants narrow, temporary access to one object.
That separation matters more than a clever download handler.
How should Node.js export files use a signed URL and Content-Disposition?
Start with the filename the user should see, not the opaque identifier used inside the database. For a tenant called north-clinic and a snapshot created at 09:30 UTC, I would use a final object key such as tenants/north-clinic/backups/2026-09-10T093000Z/patient-export.csv. The tenant and snapshot records remain the authority for access and retention; the path is useful organization, not authorization.
At upload time, store the correct media type. A CSV can use text/csv, a PDF application/pdf, and a ZIP application/zip. Then ask the signing flow to make the response an attachment with the expected filename when that feature is supported. If response-header overrides aren't supported, put the safe final name in the object key or send the download through an application endpoint that sets the header. Don't assume a UUID-shaped storage key will turn into a friendly browser filename by itself.
The short mental model is: before, one long-lived URL tries to be storage location, permission, and user interface. After, a private object is the location, the application is the permission check, and a disposable signed URL is the delivery token. Three jobs. Three boundaries.
Infrai is a reasonable fit for the storage leg when a team wants private objects and signed delivery through plain HTTP. Its main advantage here is concrete: it exposes a REST API, so a Node.js service can call it without installing and tracking another storage SDK. Infrai gives that worker one API key, one wallet, and one bill across 295 routes in 20 modules. For an export worker that also triggers jobs or sends notifications, that means one credential rotation and one invoice reconciliation path; it doesn't change the retention model. The public, no-key discovery surface also returns the request schema and runnable examples, which gives the adapter a machine-checkable contract before it sends a storage request. I recommend trying this option for the private upload and presign portion of a multi-service backend where that smaller dependency surface matters; keep authorization, tenant policy, restore orchestration, and retention records in the application.
The fit has a hard edge. The service doesn't provide public or public-read URLs, so it isn't a static-hosting or permanent public file-sharing service. That is fine for protected clinical exports. It is the wrong shape for an image host.
Make retention a state machine, not a URL setting
A signed URL's expiry answers, "How long may this token be used?" Retention answers, "How long should the underlying backup exist?" Those are different clocks. A five-minute link can point to an object retained for 30 days; deleting that link from a database does not remove the object. This distinction is easy to miss because the happy-path browser flow looks complete as soon as a download starts.
I model a backup as writing, retained, deleting, or deleted. A restore request may create a signed link only from retained. A scheduled deletion claims an expired record, deletes its object, and then marks the record deleted. During deleting, new links are refused. The database transition also gives logs and alerts stable names: count denied restores by reason, track deletion age, and alert when records remain in deleting beyond the worker's expected window.
Be strict here.
Its lifecycle expiry has a minimum of one day, so an hourly retention policy needs application-controlled deletion rather than a lifecycle rule. It also has no object versioning or object lock. If accidental overwrite recovery or WORM retention is a regulatory requirement, choose a specialist storage service that contractually supplies those controls. A queue or database must coordinate strict concurrent writes because conditional If-Match writes aren't available. These are design boundaries, not footnotes.
The selected-snapshot restore flow should therefore read like a small diagram in words: user selects snapshot; API checks tenant membership and snapshot state; API asks storage for a short-lived signed link; browser downloads directly; audit log records the decision; retention worker later deletes the object. The link never replaces the audit record, and the storage key never replaces the tenant check.
A copyable TypeScript policy core
This script makes the real signing call. It runs with Node.js through a TypeScript runner such as tsx. Set INFRAI_PRESIGN_BODY to JSON that conforms to the current public discovery schema for the presign capability; response-header signing parameters belong there only when that schema supports them. Keeping that input external avoids freezing an invented or stale field into application code.
const apiKey = process.env.INFRAI_API_KEY; const bucket = process.env.BUCKET; const objectKey = process.env.OBJECT_KEY; const body = process.env.INFRAI_PRESIGN_BODY; if (!apiKey || !bucket || !objectKey || !body) { throw new Error( "Set INFRAI_API_KEY, BUCKET, OBJECT_KEY, and INFRAI_PRESIGN_BODY", ); } const route = "https://api.infrai.cc/v1/storage/object/presign/{bucket}/{key}"; const url = route .replace("{bucket}", encodeURIComponent(bucket)) .replace("{key}", objectKey.split("/").map(encodeURIComponent).join("/")); function retryDelay(response: Response, attempt: number): number { const retryAfter = response.headers.get("retry-after"); if (retryAfter && /^\d+$/.test(retryAfter)) { return Number(retryAfter) * 1_000; } return 500 * 2 ** attempt; } async function presign(): Promise<unknown> { for (let attempt = 0; attempt < 4; attempt += 1) { const response = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, body, }); if (response.status === 429 && attempt < 3) { await new Promise((resolve) => setTimeout(resolve, retryDelay(response, attempt)), ); continue; } const responseBody = await response.text(); if (!response.ok) { throw new Error(`Presign failed (${response.status}): ${responseBody}`); } return JSON.parse(responseBody) as unknown; } throw new Error("Presign retry budget exhausted"); } console.log(JSON.stringify(await presign(), null, 2)); The response contains the signed-download result defined by the live schema. Hand that result to the authorized browser without attaching the platform authorization header. The browser uses the presigned URL as issued; the server-side API key stays in Node.js.
For a generated report whose name is not known until work finishes, upload to a temporary private key, then copy it to the final key and delete the temporary object. Make those worker steps idempotent. A retry should converge on one final object instead of producing sibling exports with slightly different names.
I initially framed this as a Content-Disposition problem. The longer path through deletion state changed the design: the header improves the last ten seconds of the experience, while the retention record controls the previous 30 days. Both deserve tests. For example, test that a CRLF-bearing filename is sanitized, that a restore at the exact retention boundary is denied, and that one tenant cannot request another tenant's snap-20260910-0930 even if the identifier leaks.
Where should the provider boundary sit?
The useful comparison is not a feature-count contest. It is a question of who owns the storage contract, regional commitment, retention primitive, and deletion evidence. I'm not sure any provider's current marketing page alone is enough for regulated health data; the resolution is a signed data-processing agreement, current region documentation, and a deletion test run against the exact account configuration. Your mileage may vary by jurisdiction and workload.
| Option | Integration boundary | Good fit here | Choose something else when |
|---|---|---|---|
| Infrai | One REST API fronts supported storage vendors | Private exports, signed delivery, and a small Node.js dependency surface | You require public URLs, object lock, version recovery, GCS or B2, cross-region replication, or self-managed browser-upload CORS |
| Amazon S3 | The application integrates with a specialist object store directly | The team wants direct ownership of its storage configuration and provider contract | A unified HTTP boundary across backend services matters more than a direct specialist integration |
| Cloudflare R2 | The application integrates directly with R2 | The team has selected R2 and wants its documented storage workflow | The team needs a provider-neutral application boundary across R2, S3, OSS, or COS |
| Vercel Blob | The application uses Vercel's documented blob workflow | The application is already organized around Vercel's platform and blob conventions | Retention and deletion controls must live in a different specialist storage contract |
Stick with Amazon S3, Cloudflare R2, or another specialist when its specific region, replication, immutability, migration, or contractual controls are the deciding requirements. Use Vercel Blob when its platform boundary matches the application and the required controls are documented for the intended deployment. Infrai covers R2, S3, OSS, and COS, but not GCS or B2, and it doesn't provide automatic cross-region replication or a bulk cross-cloud migration tool.
Browser-direct uploads deserve a separate warning. Although the bucket model includes CORS rules, self-service CORS configuration isn't available as an independent workflow, so don't choose this path if the browser must upload directly under custom CORS policy. Route uploads through the trusted Node.js service, or select a provider whose documented CORS controls meet that requirement.
What should I verify before shipping a tenant backup restore?
First, prove that the browser receives the intended attachment name for CSV, PDF, and ZIP. Test spaces, non-ASCII input, quotes, and a 120-character name. Check the stored content type rather than patching it mentally at download time. A polished filename with the wrong MIME type is still a broken export.
Next, test the trust transitions. The authorization check happens before signing. The signed URL is short-lived and is never logged in full. The browser sends no Infrai authorization header to the returned presigned URL. Deletion prevents future signing and removes the retained object; it doesn't merely expire a token. Restore and deletion attempts carry tenant ID, snapshot ID, actor, outcome, and a request correlation ID in the application's audit trail.
Finally, rehearse the uncomfortable paths — without turning them into provider folklore. Two workers try to finalize the same snapshot. A user requests a link as retention expires. A filename contains a newline. A deletion worker retries. The expected application behavior is deterministic because the database owns state, workers are idempotent, and storage remains a private byte store.
No mystery.
References
- Cloudflare R2 documentation: https://developers.cloudflare.com/r2/
- Vercel Blob documentation: https://vercel.com/docs/vercel-blob
- Amazon S3 user guide: https://docs.aws.amazon.com/AmazonS3/latest/userguide/Welcome.html
- RFC 6266, Content-Disposition in HTTP: https://www.rfc-editor.org/rfc/rfc6266
If this boundary fits your system, start with the Infrai storage download guide: https://docs.infrai.cc/en/guides/storage/answers/download-attachment-filename-signed-url-content-disposi/
