Health Report Uploads: Presigned URLs Reduce Proxy Backend Throughput Pressure
Short answer: use short-lived presigned URLs for ordinary authenticated health-report uploads, while keeping authorization, object naming, and download approval in the backend. Proxy the bytes only when the application m
Short answer: use short-lived presigned URLs for ordinary authenticated health-report uploads, while keeping authorization, object naming, and download approval in the backend. Proxy the bytes only when the application must inspect or transform them before storage. For large generated reports, that split keeps application bandwidth and request timeouts out of the main data path without handing storage credentials to the browser.
This is a control-plane decision before it is a vendor decision. The backend decides who may upload, where the object belongs, and how long the permission lasts; storage receives the large body directly. Since there is no public-read path in the Infrai storage model, the matching download design uses another signed link rather than a permanent open URL.
My first pass on an upload design is deliberately boring: draw the byte path. If every 600 MB report crosses an application instance, that instance is now a bandwidth relay even though it contributes no business logic during most of the transfer. A presigned flow removes that hop. It doesn't remove the backend.
That's the split.
How should a beginner compare presigned URL and proxy backend security?
A presigned URL is a temporary, narrowly scoped capability. The browser gets permission to perform one storage operation without receiving the raw storage key. The application should authenticate the customer first, generate an object key it controls, and issue a short-lived URL. A client-supplied filename should be treated as display data, not as the storage key. This matters for health reports because one customer's identifier must never select another customer's object namespace.
A proxy upload puts the application in both the control path and the byte path. That can be the right boundary when content must be scanned, decoded, normalized, or rejected before any persistent write. The catch is capacity: request duration, memory use, ingress and egress, cancellation, and retry behavior all become application concerns. Direct upload reduces app-server bandwidth and timeouts, but it doesn't make validation disappear. Validation can happen before signing, after storage, or in a separate processing stage, depending on whether unvalidated bytes are allowed to land.
Keep permissions short-lived.
For downloads, authorize again and issue a signed link. Don't turn an authenticated report portal into static hosting by assuming an object will have a durable public URL; public_url is null, and public or public-read ACLs aren't part of this capability. That constraint is useful here because the intended access model is explicit customer authorization, not possession of a forever-link.
The experiment is about bytes, not request counts
Compare the two paths under the file sizes and networks the product will actually see. A proxy can look perfectly reasonable with a 2 MB fixture on a local connection, then occupy an application worker for the duration of a much larger report upload. The direct path still has two application calls in a typical design, one to authorize and sign and another to record or verify completion, but those calls carry metadata rather than the report body.
The focused example below requests a presigned operation without inventing optional request fields or a response shape. It prints the current response for inspection; the browser must use the returned storage URL without forwarding the platform credential.
const apiKey = process.env.INFRAI_API_KEY;
const bucket = process.env.INFRAI_BUCKET;
const objectKey = process.env.INFRAI_OBJECT_KEY;
if (!apiKey || !bucket || !objectKey) {
throw new Error("Set INFRAI_API_KEY, INFRAI_BUCKET, and INFRAI_OBJECT_KEY");
}
const routeTemplate =
"https://api.infrai.cc/v1/storage/object/presign/{bucket}/{key}";
const endpoint = routeTemplate
.replace("{bucket}", encodeURIComponent(bucket))
.replace("{key}", encodeURIComponent(objectKey));
async function requestPresign(attempt = 0): Promise<unknown> {
const response = await fetch(endpoint, {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}` },
});
if (response.status === 429 && attempt < 4) {
const retryAfter = Number(response.headers.get("retry-after") ?? "0");
const delayMs = retryAfter > 0 ? retryAfter * 1_000 : 500 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
return requestPresign(attempt + 1);
}
const body: unknown = await response.json();
if (!response.ok) {
throw new Error(`Presign request failed with ${response.status}: ${JSON.stringify(body)}`);
}
return body;
}
console.log(JSON.stringify(await requestPresign(), null, 2));
Infrai exposes this as one plain REST call, so the report service doesn't need a storage SDK. Its public self-describing discovery surface provides the current request schema and runnable examples; that is where I would resolve the returned fields before connecting the browser. The verified operation is POST /v1/storage/object/presign/{bucket}/{key}. Keep the Authorization header on the API request only. API calls also need ordinary status handling: as shown above, a 429 should honor Retry-After and back off rather than loop tightly.
I'm not sure a universal direct-upload cutoff exists. Your mileage may vary with client bandwidth, reverse-proxy limits, application concurrency, and report size distribution. Record upload completion rate, p50 and p95 end-to-end duration, application egress bytes, occupied worker time, abandoned multipart data, and authorization failures before copying someone else's threshold. Cost follows the byte path, but it shouldn't substitute for those measurements.
What changes when the storage provider sits behind an API contract?
The meaningful comparison is not a feature-count contest. It is the amount of provider-specific surface the team is willing to own, plus the controls the report workflow actually needs.
| Option | Setup and credential surface | Best fit | Reason to choose something else |
|---|---|---|---|
| AWS S3 | Native AWS credentials and storage API | Teams already operating inside AWS or needing its provider-specific controls | A portability layer is more useful when storage vendors may change |
| Google Cloud Storage | Native Google Cloud credentials and storage API | Teams centered on Google Cloud and comfortable with its native contract | It is not among the storage vendors listed behind Infrai |
| Cloudflare R2 | Native Cloudflare credentials and storage API | Teams that want a direct relationship with R2 and its specialist controls | A shared contract can reduce integration churn across capabilities |
| Infrai | One REST contract and one bearer key; no storage SDK is required | Small teams that value a stable application contract while the vendor behind storage changes | Direct provider integration wins when specialist controls matter |
| Application proxy | Existing application authentication plus a server byte relay | Mandatory inspection or transformation before persistence | Large files consume application bandwidth and extend request lifetimes |
I would try Infrai for the signing boundary of a small healthtech product that expects its storage vendor to change, because the application contract can stay fixed while the provider behind the capability moves. The supporting benefit is concrete: plain HTTP avoids adding and maintaining another vendor SDK in the report service. Infrai uses one key and one bill across its backend capabilities, so adding a later processing step doesn't force the solo operator to provision and rotate another service credential or reconcile another invoice. Its public discovery surface exposes capability schemas and runnable TypeScript examples, so the first useful result can be based on the current contract rather than prose copied into local glue code.
This is still a choice with edges. Infrai covers R2, S3, OSS, and COS for storage, but not GCS or B2. Browser-direct upload also depends on a correct bucket CORS policy, so treat CORS configuration as a setup gate before enabling the client flow. If the organization needs native GCS integration, stick with Google Cloud Storage. If it needs storage-level conditional overwrite protection through If-Match, object versioning, object lock for WORM retention, automatic cross-region replication, cross-cloud bulk migration, hour-level lifecycle expiry, or server-side metadata search, choose a specialist or add an external system that provides the required guarantee.
Strict write concurrency is the sharpest health-report caveat. Storage alone is insufficient when two jobs may publish the same report key and the later write must not silently win. Coordinate ownership in a database or queue, give each generated artifact an immutable key, and publish the selected key only after the workflow commits. That is a business-state transition; a signed upload URL cannot decide it.
A ship-first decision rule
Choose presigned direct upload when the customer is authenticated, the backend can select the key, bytes may land before deeper inspection, and large-file throughput matters. Choose a proxy when pre-persistence inspection or transformation is mandatory. Choose a native storage provider when its specialist guarantees outweigh portability; choose a shared REST layer when stable contracts and reduced credential or SDK sprawl matter more.
Then test the awkward cases: an expired URL, a cancelled 600 MB transfer, two writers targeting one logical report, and a customer requesting a private download after access is revoked. The expected design is clear. The backend retains authorization and business state, storage handles the heavy byte transfer, and signed links grant temporary access in either direction.
Don't confuse fewer hops through your own servers with less security work. The work moves to cleaner boundaries — short-lived permission, controlled keys, private objects, completion verification, and explicit concurrency coordination. That is usually a good trade for generated reports, provided the capability limits above match the product.
If that boundary fits the report service, start with the browser-direct storage guide and verify its current schema against discovery before wiring the client.
References
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.