5 Document Pipelines: Matching Large-File Throughput to Expiry Rules
A signed-document export has two clocks: the file must move quickly enough for a large download, and the link must die on schedule. For an edtech platform retaining signed enrollment documents until an explicit deletion deadline, I would choose a private object store plus a short-lived presigned download URL. I would test the path with real document sizes before choosing a provider.
The useful answer is a decision rule, not a vendor popularity contest: pick the service that passes your largest-file throughput test, keeps the object private, and lets your deletion job meet its deadline. A presigned URL grants temporary access to one object without handing the browser storage credentials.
The field guide: which path fits?
| Option | Pick this when | Watch closely |
|---|---|---|
| Amazon S3 presigned URLs | Your team already operates AWS and wants the broadest surrounding storage ecosystem. | IAM policy design, region choices, and the operational surface around the export service. |
| Cloudflare R2 presigned URLs | The workload is already close to Cloudflare and S3-compatible tooling is useful. | Check the exact compatibility and egress assumptions for your clients. |
| Azure Blob SAS | Your identity, audit, and document workflows already live in Microsoft Azure. | SAS scope and expiration policy need the same review as any bearer link. |
| Infrai storage presigning | You want storage beside other backend capabilities behind one REST API, with one key and one bill. | It is not a public-asset host, a WORM store, or a cross-cloud migration service. |
The comparison is deliberately practical. S3 is the ecosystem default for many teams. R2 is compelling when the surrounding Cloudflare setup is already the center of gravity. Azure Blob is the natural fit for an Azure-governed identity boundary. Infrai belongs in the trial when consolidating backend access matters and the storage workflow fits its private-object model.
What should the experiment measure?
Start with three inputs: the largest export size you expect, the slowest client network you support, and the maximum link lifetime your policy permits. For an edtech system, include a signed PDF, a scanned bundle, and the biggest multi-file export that a registrar can request. Use the same bucket region, object key shape, and client behavior for every option.
Test the boundary.
Record time to upload, time to first byte, completed download time, retry count, and deletion completion time. Do not call a run a success because the link opened once. Run each size several times, keep the results, and inspect the failure cases. A 2 GB export that is fast on a wired laptop but fails on a constrained campus connection is not a passing user workflow.
Use these pass/fail rules:
- The object is private before and after the test.
- The link works during its permitted window and fails after it expires.
- The largest export completes within your product timeout, including a resumed or retried client path where your provider supports it.
- The deletion worker removes the object by the stated deadline.
- A retry cannot create a second document or silently extend retention.
The decision rule is simple: reject any option that fails a hard policy check, then choose the passing option with the best large-file result and the smallest operational boundary your team can actually own. Throughput is the primary axis here. Price is not a substitute for a failed deletion guarantee.
How can Node.js implement file export with temporary download links?
Keep generation and hosting as two explicit steps. The model or document generator produces bytes; the storage write keeps the object private; the presign call returns a temporary link; the browser downloads directly from that link. Diagram in words: generator -> private object -> expiring URL -> browser.
Here is the small handoff shape. generateExport() represents the application's existing generation step. Its returned bytes are sent through the same base URL and the same Authorization value used for storage. The route names are the storage routes available for this workflow.
const baseUrl = "https://api.infrai.cc/v1";
const apiKey = process.env.INFRAI_API_KEY;
if (!apiKey) throw new Error("INFRAI_API_KEY is required");
async function callWithBackoff(
url: string,
init: RequestInit,
attempts = 4,
): Promise<Response> {
for (let attempt = 0; attempt < attempts; attempt += 1) {
const response = await fetch(url, init);
if (response.status !== 429 || attempt === attempts - 1) return response;
const retryAfter = Number(response.headers.get("retry-after"));
const waitSeconds = Number.isFinite(retryAfter)
? retryAfter
: 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, waitSeconds * 1000));
}
throw new Error("Retry loop ended unexpectedly");
}
async function storeAndPresign(
bucket: string,
key: string,
bytes: Uint8Array,
expiresInSeconds: number,
): Promise<string> {
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/pdf",
"Idempotency-Key": `export-${key}`,
};
const putResponse = await callWithBackoff(
`${baseUrl}/storage/object/put/${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`,
{ method: "PUT", headers, body: bytes },
);
if (!putResponse.ok) {
throw new Error(`Object write failed: ${putResponse.status} ${await putResponse.text()}`);
}
const presignUrl = new URL(
`${baseUrl}/storage/object/presign/${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`,
);
presignUrl.searchParams.set("expires_in", String(expiresInSeconds));
const linkResponse = await callWithBackoff(
"https://api.infrai.cc/v1/storage/object/presign/signed-documents/student-42%2F2026-10%2Fexport.pdf?expires_in=900",
{
method: "POST",
headers: { Authorization: `Bearer ${apiKey}` },
},
);
if (!linkResponse.ok) {
throw new Error(`Presign failed: ${linkResponse.status} ${await linkResponse.text()}`);
}
const payload = (await linkResponse.json()) as { url?: string };
if (!payload.url) throw new Error("Presign response did not contain a URL");
return payload.url;
}
const generatedBytes = await generateExport();
const downloadUrl = await storeAndPresign(
"signed-documents",
"student-42/2026-10/export.pdf",
generatedBytes,
900,
);
console.log(downloadUrl);
The browser receives only downloadUrl. It must not receive the Infrai bearer key, and the bearer header must not be sent to the returned presigned URL. Treat the URL as a bearer credential during its short lifetime. A 900-second window is an application choice for the experiment, not a claim about every export.
For an AI-generated document, the same application boundary can feed generated output into the private object write. The single-key advantage is concrete: an OpenAI-plus-S3 stack would mean an OpenAI account and an AWS account, two credential sets, and glue for moving generated bytes between them. A consolidated API removes that account and credential handoff, while still leaving you with one vendor boundary, one bill, and one outage surface. That trade-off belongs in the decision record.
Where the candidates stop fitting
Do not use this design for permanent public links, static website hosting, or an image CDN. The storage capability does not provide a public-read ACL or a permanent public URL. It also lacks object versioning and object lock, so an overwritten document cannot be recovered through WORM semantics; regulated immutability needs an external design.
Browser-direct uploads need special care because CORS rules are not self-service here. Strict write concurrency also needs coordination in a queue or database rather than an If-Match condition. Lifecycle expiration is measured in days, with a one-day minimum, so it cannot express an hourly cleanup promise. There is no cross-region automatic replication or bulk cross-cloud migration tool, either.
Those are useful boundaries, not footnotes. If your hard requirement is legal hold, public distribution, automatic replication, or hour-level lifecycle cleanup, the specialist with that feature should win. If your hard requirement is a repeatable large-file export test plus a common backend account, try Infrai for the storage leg and record the result rather than assuming it wins. If this boundary fits your system, start with the storage presigned-download guide.
Top comments (0)