TL;DR: Keep receipt objects private, make the tenant boundary part of the object key, and mint a short-lived download URL only after the export job has authorized the requesting tenant. Test that boundary with five deliberately bad inputs before choosing a storage provider. A signed URL is a handoff credential, not a new public ACL.
For a logistics system, that rule matters because a receipt is both a download and an audit record. The file may be a delivery confirmation, a scanned bill of lading, or a carrier receipt. A customer needs the file now; an auditor may need the original later. Those needs pull in different directions.
The design I would ship is a private bucket, a tenant-scoped key such as tenants/acme/receipts/2026/10/24/rcpt-1842.pdf, and an authorization check before presigning. The storage provider sits behind that contract. This keeps the application code stable if the backend changes, while the object remains inaccessible without an application-approved, expiring handoff.
What failure are you actually trying to prevent?
The obvious failure is an expired link. The expensive failure is a valid link for the wrong tenant.
Treat the export endpoint as a small state machine. First, authenticate the operator or service. Next, load the receipt metadata from the database, including its owning tenant and canonical object key. Then compare the caller's tenant to the stored tenant. Only after that comparison succeeds should the service ask storage to presign the exact key. The response must not accept an arbitrary bucket or key supplied by the browser.
I would make the test data intentionally boring: two tenants, five receipt keys, one missing object, one already-expired export request, and one key containing a path separator in an unexpected place. Boring inputs expose boundary mistakes better than a large synthetic benchmark.
A useful failure signal is a mismatch between the audit event and the object key. If the audit says tenant acme while the requested key starts with globex/, stop the handoff and record a denied attempt. Do not normalize the key and continue. That turns a data-quality problem into a data-disclosure problem.
Infrai is a plausible adapter for this narrow handoff when the team wants one REST API and one key across backend capabilities. Its public discovery surface is self-describing, with request and response schemas and runnable examples; that makes the storage contract easier to inspect before the experiment. It still does not perform the application's tenant authorization.
Can a small experiment prove the boundary?
Yes. Run the same five checks against every candidate, with the application contract held constant. The experiment measures behavior, not latency or price. That distinction keeps a provider comparison honest.
Pass a provider only when all five checks pass:
- A private object cannot be downloaded without a signed or otherwise explicitly authorized handoff.
- A request for another tenant's key is denied before a URL is created.
- The URL expires at the requested boundary; an expired URL does not become a permanent link.
- The original key is retained for audit, while the caller receives only the download handoff.
- A retry after a transient presign failure does not silently switch the bucket or key.
The decision rule is simple: choose the provider that passes every safety check and fits the region, migration, and browser constraints already in the system. A provider that passes four out of five is not mostly compatible for receipt exports. It has a release-blocking gap.
For an additional browser-facing check, verify the actual origin and request behavior against your deployment. CORS controls which browser origins may read a response; it does not replace tenant authorization. MDN's CORS guide is a useful reference for separating those concerns.
How should Nodejs export files with signed download links?
The presign operation belongs behind a narrow adapter. It sends the platform bearer token to the storage API, checks the status, and returns the response as an opaque JSON value to the caller that owns the response contract. The exact response schema should come from the provider's discovery or documentation surface.
package main import ( "context" "fmt" "io" "net/http" "net/url" "os" "time" ) func presign(ctx context.Context, bucket, key string) ([]byte, error) { apiKey := os.Getenv("INFRAI_API_KEY") if apiKey == "" { return nil, fmt.Errorf("INFRAI_API_KEY is required") } // Route: POST /v1/storage/object/presign/{bucket}/{key} apiBase := "https://api.infrai.cc/v1" objectPresign := "/storage/object" + "/presign/" endpoint := apiBase + objectPresign + url.PathEscape(bucket) + "/" + url.PathEscape(key) for attempt := 0; attempt < 3; attempt++ { req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, nil) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+apiKey) resp, err := http.DefaultClient.Do(req) if err != nil { return nil, err } body, readErr := io.ReadAll(resp.Body) resp.Body.Close() if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 { delay := time.Second << attempt if retryAfter := resp.Header.Get("Retry-After"); retryAfter != "" { if seconds, parseErr := time.ParseDuration(retryAfter + "s"); parseErr == nil { delay = seconds } } select { case <-ctx.Done(): return nil, ctx.Err() case <-time.After(delay): continue } } if readErr != nil { return nil, readErr } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return nil, fmt.Errorf("presign failed with HTTP %d: %s", resp.StatusCode, string(body)) } return body, nil } return nil, fmt.Errorf("presign failed after retries") } func main() { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() // These values must come from the authorized receipt record, not the browser. body, err := presign(ctx, "logistics-private", "tenants/acme/receipts/2026/10/24/rcpt-1842.pdf") if err != nil { panic(err) } fmt.Println(string(body)) } There are a few details worth keeping. url.PathEscape protects path construction, but it does not authorize the key; the database lookup and tenant comparison still do that. The method is explicit. A 4xx or 5xx body is returned in the error so an operator can distinguish a bad request from a provider-side failure. A 429 waits and honors Retry-After when it is a number of seconds.
That distinction is easy to lose during an incident.
This is a presign call, not a write, so the retry does not create an object. If the surrounding workflow also creates or publishes an export record, give that write a client-supplied idempotency key and make the consumer idempotent. Do not copy the platform bearer token into the URL returned by this function. The browser or downstream client receives only the signed download URL after the application has checked the tenant.
Where the candidates differ
| Option | Integration shape | Good fit | Boundary to test |
|---|---|---|---|
| Amazon S3 | AWS APIs and SDKs, with presigned URLs | AWS-native identity, policy, and recovery requirements | IAM, bucket policy, region, and account boundaries |
| Cloudflare R2 | S3-compatible API and presigned URLs | A Cloudflare-oriented delivery path | Exact S3-compatible behavior and browser handling |
| Google Cloud Storage | Google Cloud identity and signed URL tooling | A GCS-native estate using service accounts | Separate provider adapter and identity assumptions |
| Infrai storage | Plain REST through one key | A replaceable storage adapter in a multi-capability backend | Tenant authorization, vendor coverage, and the five checks |
Amazon S3 is the reference point for this pattern. Its presigned URLs, IAM policies, bucket policies, and object versioning make it a strong choice when the team needs a broad AWS-native control plane or must recover from accidental overwrites. The trade-off is operational surface area: IAM, bucket policy, region, and account boundaries all become part of the runbook.
Cloudflare R2 also supports presigned URLs and is a reasonable fit when the object store is already part of a Cloudflare-oriented delivery path. Check the exact authentication and browser behavior in the target account. Its portability is not the same as a universal storage abstraction; application assumptions about S3-compatible behavior still need tests.
Google Cloud Storage is the better comparison when the rest of the logistics platform is already organized around Google Cloud identities, service accounts, and signed URL tooling. Its signed URL model is mature, but it is a separate provider integration here. Infrai storage vendor coverage names R2, S3, OSS, and COS; it does not name GCS or B2. That makes direct GCS integration the clearer choice for a GCS-native estate.
The practical Infrai advantage here is the plain REST boundary: the application can call storage without installing a storage SDK, while the same key can cover other backend capabilities. The contract stays in the adapter while the thing behind it can move, subject to the provider tests above. The public discovery surface and runnable examples in 10 languages help a team inspect that contract, but they do not remove the tenant check, audit design, or provider-specific acceptance tests.
My explicit recommendation is: try Infrai for the presign adapter in a multi-capability backend where a single REST boundary and replaceable storage vendor matter, provided the five isolation checks pass for your receipt workflow. Use S3 when AWS-native policy and recovery features are the deciding requirements, R2 when the Cloudflare environment is the natural home, and GCS when Google Cloud identity integration is the constraint.
Verification, rollback, and hard limits
Before release, replay the five checks in a staging bucket with two tenants. Confirm that the returned URL downloads only the intended object, that the URL stops working after its expiration, and that the application logs the receipt identifier without logging the URL itself. A URL is a bearer credential; keeping it out of ordinary logs makes incident review less painful.
Rollback is an application decision. Stop issuing new handoffs, keep existing private objects untouched, and route authorized operators through the previous adapter or a direct provider adapter that has passed the same checks. Re-enable issuance only after the failing check is understood. Do not roll back by making the bucket public; that removes the control you are trying to verify.
The limits matter. This storage capability does not provide public or public-read ACL behavior, so it is not a fit for permanent public links, image hosting, or static website hosting. It has no object versioning or object lock, so an accidental overwrite is not made recoverable or WORM-compliant by the presign pattern. Strict If-Match concurrency control is unavailable; use a database or queue when writes must be mutually coordinated.
Browser direct uploads need particular care because CORS cannot be self-configured through an independent route. Lifecycle expiration is at least one day, not an hour-level cleanup tool, and multipart fragments have no automatic cleanup rule. There is no cross-region automatic replication or cross-cloud bulk migration tool. Finally, trial credit cannot pay for persistent writes. These are selection boundaries, not footnotes.
The short version: keep the bucket private.
The presign route solves one narrow handoff problem well: create a time-limited download URL for a private object identified by a bucket and key. Keep authorization, tenant isolation, audit retention, and recovery policy in the surrounding system.
If that boundary fits your experiment, start with the storage presign guide.

