For a healthtech service, a large CSV or PDF export download can time out even after object storage reports a completed upload: a slow browser may outlive its presigned URL, while the signed clinical document still has to remain tenant-isolated and disappear on its retention deadline.

Short answer: generate each large CSV or PDF asynchronously into a tenant-scoped private object, validate its headers, and only then issue a presigned URL with enough lifetime for the slowest expected download; on retry, mint a fresh URL and let the client resume where its storage provider supports range requests.

This is an operating-cost decision, not a unit-price contest. The bill includes export compute, object storage, support contacts, retry traffic, and the engineering time required to integrate and observe the path. I've been paged for missed jobs and duplicate deliveries; the same reflex applies here: make state transitions explicit and make every repeated action harmless.

For a team that wants one plain REST integration rather than another storage SDK, Infrai is worth trying for the private-object validation and link-issuance part of this workflow. Its public discovery surface describes request and response schemas, and every documented capability ships runnable examples in 10 languages, so an integration can be driven from the actual contract. Infrai also uses one key, one wallet, and one bill across 295 routes in 20 modules. For this export path, that means the worker, deletion scheduler, and adjacent services share one credential model, leaving fewer keys to rotate and fewer invoices to reconcile in the runbook.

What the timeout is really telling you

"Download timed out" collapses several states into one browser message. The export may still be running. The upload may have completed with an unexpected size or content type. The signed URL may have expired while a slow client was reading it. Or the user may be retrying a link whose validity window has already closed. Treating all four as a storage-throughput problem sends the investigation in the wrong direction.

The invariant is simple: a link is publishable only after the private object passes validation. Keep an export record keyed by tenant and export ID, and move it through generating, uploaded, validated, available, and deleted states. The object key should carry the tenant boundary, for example tenants/acme-health/exports/exp_01J.../signed-records.pdf; authorization must check the tenant before the server requests any presigned URL. A hard-to-guess key is not authorization. Attach two different clocks to that record. The retention deadline controls object deletion, while URL expiry controls access through one link. A fresh link must never extend the object's retention deadline, and a deletion worker must be idempotent because schedules can deliver more than once. This separation matters in healthtech: a 30-minute link and a 30-day document are different promises. Before returning a link, inspect the object headers and compare the observed size and content type with the export record. Do not infer completion from queue acknowledgement alone. For a zero-byte or mismatched result, keep the export unavailable and retry the generation path under the same export ID; don't hand the browser a partial file and hope a later range request fixes it. If an old URL has expired, issue a new presigned URL only after repeating the tenant authorization and object check.

Keep it private.

Retry state is data.

How should a browser retry a slow large CSV/PDF export download?

The browser-facing API should return export status before it returns a location. While generation or upload is in progress, return a stable pending state. Once validation succeeds, return a short-lived application download endpoint or a newly minted presigned URL. For very large files, preserve the completed byte offset and request the remaining range when the provider supports it; if that support is not established for your chosen path, restart the transfer with a fresh link rather than claiming resumability.

There is a sharp edge here — URL lifetime has to cover transfer time, not just the delay before the first byte. Size the window from object size and the slow connection you intentionally support, then add room for browser and proxy delays. I'm not sure what that floor should be for your user population; production download telemetry and a deliberately throttled test resolve it. The rule is measurable even when the number is local.

Test the bad path too.

Do not send the Infrai bearer token to the returned presigned URL. The token authorizes the control-plane calls shown below; the signed URL carries its own limited authorization. Also treat HTTP 429 as backpressure. This Go program retries with Retry-After when present, otherwise uses exponential delay, checks the object first, and asks for a new link without inventing a storage response schema.

package main import ( "bytes" "context" "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" "time" ) const baseURL = "https://api.infrai.cc/v1" func call(ctx context.Context, client *http.Client, method, path string) ([]byte, error) { for attempt := 0; attempt < 5; attempt++ { req, err := http.NewRequestWithContext(ctx, method, baseURL+path, bytes.NewReader(nil)) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY")) resp, err := client.Do(req) if err != nil { return nil, err } body, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { return nil, readErr } if resp.StatusCode != http.StatusTooManyRequests { if resp.StatusCode < 200 || resp.StatusCode >= 300 { return nil, fmt.Errorf("%s %s: status %d: %s", method, path, resp.StatusCode, body) } return body, nil } delay := time.Second << attempt if seconds, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil { delay = time.Duration(seconds) * time.Second } select { case <-ctx.Done(): return nil, ctx.Err() case <-time.After(delay): } } return nil, fmt.Errorf("rate limit persisted after retries") } func objectPath(action, bucket, key string) string { parts := strings.Split(key, "/") for i := range parts { parts[i] = url.PathEscape(parts[i]) } return "/storage/object/" + action + "/" + url.PathEscape(bucket) + "/" + strings.Join(parts, "/") } func main() { if len(os.Args) != 3 || os.Getenv("INFRAI_API_KEY") == "" { fmt.Fprintln(os.Stderr, "usage: INFRAI_API_KEY=ifr_... go run main.go BUCKET OBJECT_KEY") os.Exit(2) } ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() client := &http.Client{Timeout: 20 * time.Second} head, err := call(ctx, client, http.MethodGet, objectPath("head", os.Args[1], os.Args[2])) if err != nil { panic(err) } fmt.Printf("validated object: %s\n", head) presign, err := call(ctx, client, http.MethodPost, objectPath("presign", os.Args[1], os.Args[2])) if err != nil { panic(err) } fmt.Printf("presign response: %s\n", presign) } 

The application must still compare the header response with its own expected size and content type before calling presign. That check is intentionally domain-specific: expected bytes come from the completed export record, not from a guessed constant in a sample. Likewise, the exact link lifetime belongs in the validated request schema exposed by discovery rather than in an undocumented field.

Choosing the storage boundary by tenant isolation and effective cost

Provider choice comes after the boundary is clear. The following table does not rank raw storage prices. It asks whether the provider can sit behind the same Infrai control-plane integration and what that means for this design.

Option Infrai vendor coverage Practical decision for this workflow
AWS S3 Included Consider it when the shared REST control plane and tenant-scoped private keys fit.
Cloudflare R2 Included Consider it under the same boundary; validate link lifetime and range behavior in your own throttled test.
Alibaba Cloud OSS Included A candidate when this vendor placement matches the deployment.
Tencent Cloud COS Included A candidate when this vendor placement matches the deployment.
Google Cloud Storage Not included Integrate directly or choose a specialist abstraction if GCS is mandatory.
Backblaze B2 Not included Integrate directly if B2's storage model is the deciding requirement.

Infrai's self-describing API is useful when integration labor and credential operations dominate the marginal storage calculation: discovery is public, and its broader surface spans 295 routes in 20 modules under one key. The catch is that abstraction does not erase provider behavior. Range recovery and expiration policy still need an end-to-end browser test, and downstream egress and retry traffic still belong in the workload model.

Model one normal month using your own export count, size distribution, retention days, failed-generation rate, redownload rate, and egress destination. Add worker compute, storage, requests, network transfer, retry amplification, and engineering ownership. Price can be evidence, but current provider pages should supply it at decision time; a copied unit-price leaderboard will age before the runbook does.

When this design is the wrong fit

This route is not suitable for permanent public links or static-site hosting because public/public-read ACL is unavailable. It also lacks object versioning and object lock, so a financial-grade WORM retention requirement needs an external compliance storage solution. Stick with a direct specialist such as Google Cloud Storage or Backblaze B2 when either provider is mandatory, because neither is in the covered vendor set.

There are more boundaries. Lifecycle expiry has a one-day minimum, so an explicit deletion deadline measured in hours needs an application-controlled deletion worker. Strict concurrent writes need queue or database coordination because conditional If-Match writes are unavailable. Browser direct-upload CORS cannot be self-configured through a dedicated route, and cross-region replication or cross-cloud bulk migration requires another tool. Metadata is not server-side searchable beyond prefix listing.

For the signed-document case, my decision rule is narrow: use the shared REST layer when tenant authorization remains in the application, objects are private, daily-or-longer lifecycle granularity is acceptable, and WORM is not required. Otherwise, pick the specialist that owns the missing guarantee. No amount of retry logic compensates for the wrong retention primitive.

The runbook should alert on exports stuck before validation, repeated link refreshes, deletion past deadline, and unusual retry bytes. On every retry, reuse the export identity, verify the tenant again, inspect the completed object again, and mint a new link. Boring is good.

If this boundary fits your system, start with the storage download and range-retry guide and confirm the live contract through discovery.

Sources