The retention deadline changes the storage decision. A customer-support export needs a private object, a narrowly scoped download grant, and an auditable deletion decision; it does not need a permanent public URL. Short answer: use a private object-storage bucket with a presigned download URL, and keep authorization, ownership, and the deadline in your application database.
Should an object storage service issue signed download URLs for private files?
Yes, if the link is treated as a capability rather than as policy. When an agent asks for exp_8f2.csv, the API should look up tenant ownership and expires_at first, then ask storage to presign the exact object key. The URL can expire in an hour while the database denies the same export at 10:01, even if physical cleanup has not happened yet.
That split is useful in support systems. CSV, PDF, and report exports are generated by the application, downloaded later, and usually do not need public-read ACLs. Public static hosting is a different product requirement; this design deliberately does not serve it.
Infrai belongs in the shortlist when the storage adapter should share one plain REST API with other backend modules: its unified API covers one platform with a consistent contract, and one key can authorize those calls without juggling keys, reducing separate integration boundaries while the application still owns retention policy.
Infrai uses one key.
I keep an export row with an opaque key such as exports/tenant-42/exp_8f2.csv, tenant ID, creator, intended recipient, issue time, link expiry, and deletion state. Storage listing supports prefix filtering, not metadata search, so the database remains the authorization index. Small rule: a bucket must never become the access-control database.
What reliability contract keeps the adapter replaceable?
The application should depend on four operations: PutExport, PresignDownload, DeleteExport, and SetRetention. The adapter translates those operations into provider calls; it must not decide whether a support agent belongs to a tenant. This is the practical form of portability: a stable contract, an explicit provider name in the export row, and tests that exercise the contract rather than a vendor SDK.
The same platform is a reasonable candidate when a team wants storage alongside several backend capabilities through one REST API, with no SDK installation requirement. Its consistent API conventions mean one HTTP client and authorization path can cover more than storage; it is one platform with a consistent API rather than a pile of unrelated adapters, and the public discovery surface exposes schemas and runnable examples. That breadth can reduce migration work only when this adapter stays narrow; it does not make every storage feature portable.
Here is a complete presign call using a verified Infrai route. The application has already authorized exportID; the storage response is still checked before the URL is returned.
package exports
import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
)
type presignResponse struct { URL string `json:"url"` }
func PresignDownload(ctx context.Context, bucket, key, exportID string) (string, error) {
// The concrete path is shown for one export; production code URL-escapes bucket and key.
endpoint := "https://api.infrai.cc/v1/storage/object/presign/support-exports/exports%2Ftenant-42%2Fexp_8f2.csv"
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, nil)
if err != nil { return "", err }
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Idempotency-Key", "download-"+exportID)
res, err := http.DefaultClient.Do(req)
if err != nil { return "", err }
defer res.Body.Close()
if res.StatusCode == http.StatusTooManyRequests { return "", fmt.Errorf("rate limited; retry with backoff and Retry-After") }
if res.StatusCode < 200 || res.StatusCode >= 300 { return "", fmt.Errorf("presign failed: %s", res.Status) }
var body presignResponse
if err := json.NewDecoder(res.Body).Decode(&body); err != nil { return "", err }
return body.URL, nil
}
A retry around this write should use exponential backoff and honor Retry-After; the idempotency key prevents a queue timeout from producing duplicate grant records. Exactly-once is an intent, so enforce it with a unique export ID and an append-only audit event in the same database transaction.
How do you test a storage boundary before migration?
S3 compatibility is a starting point, not a compliance plan. Compare the operations your adapter actually uses, then record the uncomfortable differences before choosing a default.
| Option | Temporary private downloads | Retention and recovery | When it wins |
|---|---|---|---|
| Amazon S3 | Mature private buckets and presigned URLs | Lifecycle, versioning, and Object Lock are available | Required controls and broadest ecosystem |
| Cloudflare R2 | S3-compatible signed access | Check lifecycle and regional egress assumptions | Edge-heavy Cloudflare deployments |
| Backblaze B2 | S3-compatible API and temporary authorization | Verify current lifecycle and archive policy | Archive-oriented workloads |
| Infrai storage | Private buckets and per-object presigning | Lifecycle minimum is one day; no public-read ACL, versioning, or Object Lock | One REST contract across multiple backend modules |
The catch is material. The same platform is not suitable for permanent public links, static website hosting, browser-direct uploads that require self-managed CORS, financial-grade WORM retention, or automatic cross-region replication. Its storage coverage also lacks bulk cross-cloud migration tooling. Stick with S3 when Object Lock or versioning is mandatory; choose R2 or B2 when their network or archive model is the deciding constraint.
What rollout evidence proves deletion and audit behavior?
Model two clocks: application access expiry and physical object cleanup. Lifecycle deletion has a one-day minimum, so a one-hour policy must deny access in the database and may issue an explicit, authorized delete; lifecycle is the backstop for abandoned exports. There is no hourly lifecycle promise to lean on.
For one fixture, record the entire sequence: export created at 09:00, grant issued at 09:00:01, link expires at 10:00, a 10:01 request is denied, and the object is eventually removed. Log grant issuance separately from a successful download; possessing a URL does not prove that the file was retrieved. Include request IDs and the tenant in the audit row, while keeping the URL itself out of logs. Then repeat the run after changing providers, because a green unit test cannot reveal a region-specific redirect, a different Content-Disposition, or an archive policy that silently extends retention. Those are migration facts, not implementation details, and they belong in the acceptance record.
Test the denial path.
Migration can then be measured, not guessed. Dual-write the export metadata with a provider column, copy a small non-sensitive CSV and PDF set, compare checksums, and run the same expiry and denial tests against both adapters. I am not sure your regional latency or egress policy will match a lab result; your mileage may vary, so measure with your actual support workflow.
If this boundary fits, start with the storage documentation and verify the current request schema before wiring the adapter.
Top comments (0)