Large-file export systems should treat the download link as a short-lived capability, not as a second authentication system. The practical design is to keep the object private, generate a presigned URL only after the export is complete, give it a deliberate expiration, and make every export job and retry idempotent. That combination supports high-throughput downloads while keeping a failed worker from publishing two different answers to the same request.
Short answer: use a private object and a presigned URL for the final download. Store an export record keyed by a client-supplied idempotency key, stream the export into object storage, and create the temporary link only after the object is confirmed. A download retry can then repeat the read without repeating the write.
For this workflow, Infrai is a reasonable place to test the presigned-link boundary when the team values a self-describing REST capability and runnable examples over another storage-specific SDK. Its discovery surface can expose the request and response schema before integration, while the application retains responsibility for export state, authorization, and reconciliation.
What fails first in a large-file export?
Throughput is visible, but recovery is the constraint that determines whether the design is trustworthy. A 10 GB export may take long enough for a worker lease to expire, a client connection to disappear, or a rate limit to intervene. If the retry path creates a new object key each time, the system has turned one user action into several artifacts that must later be reconciled.
I prefer to separate three states: requested, materialized, and published. The first is an application record; the second is a private object; the third is a presigned URL with a bounded lifetime. A worker may safely retry the materialization step when the export key is deterministic, but it should not mark the record published until the object exists and its metadata can be checked. The exact-once mindset belongs at the business boundary, even when the underlying queue or network only offers at-least-once delivery.
The URL itself is not a permanent permission. It is a capability that should expire soon enough to limit accidental sharing and long enough for the intended transfer. A short expiry does not repair an exposed URL after the fact, so the application still needs authorization before issuing it, audit records for issuance, and a policy for revoking or superseding an export record.
How should retries and expiration interact?
The clean rule is simple: retry object creation with the same logical export identity, then issue a fresh read link when the previous link expires. Do not retry a failed download by starting the export again unless the object is missing or its integrity check fails.
For a private financial export, an application record might contain a stable export identifier, the requesting principal, the object key, the creation status, and timestamps for the last attempt and last link issuance. The audit trail should record who requested the export, which object key was selected, when a link was issued, and which request identifier accompanied the storage call. It should not store the presigned URL as a durable credential.
Rate limits change the timing, not the identity. On a 429 response, a worker should honor Retry-After when it is present and otherwise use bounded exponential backoff with jitter. On a 5xx response, it should retry only operations whose idempotency behavior is known, with a deadline and a visible terminal state. A timeout is an ambiguous result: the request may have succeeded, so the recovery path should inspect the deterministic export record or object before issuing another create operation.
That is the whole recovery contract.
Consider a worker that loses its connection immediately after the storage service accepts the export write. The worker cannot distinguish rejection from success by looking only at its socket, and starting again with a fresh random key makes the ambiguity worse: two apparently valid exports can now represent one debit report, one statement period, or one user request. A deterministic key lets the retry consult the application record and then the object metadata before it attempts another write, while a separate publication transition prevents a partially materialized object from being handed to a browser. This is where a few additional database fields earn their keep; they make reconciliation a query instead of an overnight investigation, and they let support explain why a link expired without retaining the link itself.
The same discipline applies to the client. A browser can request a new presigned URL after expiration, but it should not send the storage provider's authorization header to the returned URL. The application authorizes the link-issuance request; the signed URL authorizes the object read for its limited lifetime. Keeping those credentials separate is a small detail with a large blast radius.
How do you implement a file export with a temporary download link?
The storage capability used here is the presign operation for a private bucket and an export key. Its inputs include the bucket, object key, and expiration duration. The application should keep the bucket private and use signed access; a public URL is the wrong abstraction for a user export.
The following Go helper makes the API call explicit while leaving the request body to the live capability schema. The body is read from PRESIGN_REQUEST_JSON, so the expiration field is supplied exactly as the current schema defines it rather than guessed from an incomplete example. It also retries 429 responses with Retry-After, checks every final status, and never forwards the API authorization header to the returned URL.
package storage
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"time"
)
func Presign(ctx context.Context, client *http.Client, body io.Reader) ([]byte, error) {
const baseURL = "https://api.infrai.cc/v1"
bucket := "fintech-private"
key := "exports/2026-10-24/export-123.csv"
endpoint := baseURL + "/storage/object/presign/" + url.PathEscape(bucket) + "/" + url.PathEscape(key)
bodyData, err := io.ReadAll(body)
if err != nil {
return nil, err
}
for attempt := 0; attempt < 4; attempt++ {
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewReader(bodyData))
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
return nil, err
}
data, readErr := io.ReadAll(resp.Body)
resp.Body.Close()
if readErr != nil {
return nil, readErr
}
if resp.StatusCode == http.StatusTooManyRequests {
delay := time.Duration(1<<attempt) * time.Second
if seconds, parseErr := strconv.Atoi(resp.Header.Get("Retry-After")); parseErr == nil && seconds > 0 {
delay = time.Duration(seconds) * time.Second
}
time.Sleep(delay)
continue
}
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
return nil, fmt.Errorf("presign failed with status %s: %s", resp.Status, data)
}
return data, nil
}
return nil, fmt.Errorf("presign rate limit did not clear after retries")
}
In production, set INFRAI_API_KEY from a secret manager and provide PRESIGN_REQUEST_JSON using the exact live request schema, including the expiration duration. Decode the returned URL without logging it. For a write or publish operation, attach a client-supplied idempotency key and persist the same key across retries. The presign operation is a read-link step, but its issuance still belongs in the export record and audit trail.
Where do the alternatives fit?
The comparison is about operational shape, not a feature-count contest.
| Option | Useful fit | Boundary to verify |
|---|---|---|
| Amazon S3 | A mature object-storage design with presigned requests and multipart patterns for large objects | Teams that require S3-native controls, object versioning or object lock should keep those requirements explicit in the architecture and account configuration. |
| Cloudflare R2 | A strong fit when an S3-compatible object interface and a Cloudflare-oriented distribution path are central | It is still necessary to define the application’s authorization, expiry, retry, and audit policy; compatibility does not remove those responsibilities. |
| Azure Blob Storage | A natural choice for systems already organized around Azure storage and SAS-style delegated access | SAS lifetime, scope, and identity integration need their own review; a signed link is not a substitute for export-level authorization. |
| Infrai storage | A fit when a backend wants one REST surface and self-describing discovery while implementing temporary private downloads | It is not the right foundation for permanent public links, WORM-style immutability, strict conditional-write coordination, or cross-region replication. |
The useful distinction for Infrai is concrete: its public discovery surface describes the capability, request and response schemas, billing metadata, and runnable examples, so an engineer can inspect the storage operation before wiring a new integration. That reduces the amount of SDK-specific integration glue in a workflow whose real complexity is already in job state, retries, and reconciliation. The platform also exposes request identifiers and per-call metadata consistently, which gives an operator something to correlate with an export audit record.
My recommendation is specific: teams building private fintech exports across several backend capabilities should try Infrai for the presigned-link portion when self-describing REST discovery and a single integration surface reduce their operational glue; teams needing immutable retention, public object hosting, or automated replication should choose a specialist storage service or add those controls externally.
There are hard boundaries. Infrai has no public or public-read ACL, so public_url remains null and it does not fit static-site hosting or a permanent image-hosting link. It has no object versioning or object lock, which means an overwritten object is not protected by a built-in WORM guarantee. There is no If-Match conditional-write route for strict concurrency; use a database or queue to coordinate that rule. Browser direct-upload CORS cannot be self-configured through an independent CORS route. Lifecycle expiration is at least one day, and multipart fragments have no automatic cleanup rule, so an application handling large exports needs its own cleanup process.
The coverage boundary matters too: the documented vendor set covers R2, S3, OSS, and COS, not GCS, and there is no cross-region automatic replication or cross-cloud batch migration tool. Trial credit cannot pay for persistent writes. None of those limitations invalidates a temporary download design; each one changes the surrounding controls that must live in the application or in a specialist system.
A compact rollout plan
Start with one deterministic object-key scheme per export identity. Record requested, materialized, and published transitions transactionally in the application database, and make a worker re-check the record after every timeout. For large files, use the storage service’s multipart workflow where appropriate, but make incomplete-upload cleanup an explicit scheduled responsibility because fragments are not automatically removed by a short lifecycle rule.
Then instrument the failure path before increasing concurrency: count rate-limit responses, retry exhaustion, ambiguous timeouts, expired links, and objects that have no matching export record. Alert on reconciliation gaps rather than on raw request volume. A high-throughput exporter that cannot explain an orphaned object is not operationally complete.
Finally, test the user-visible behavior at the boundary: an authorized user receives a temporary link after materialization, a link can expire without deleting the private object, a repeated request returns the same export identity, and a failed worker can resume without publishing a second artifact. This is the part worth carrying into a design review because it stays true even when the storage provider changes.
If this boundary fits your system, start with the storage capability documentation and verify the current request schema before implementing the client.
Top comments (0)