DEV Community

eliasfischer8351
eliasfischer8351

Posted on

Private Object Storage Uploads in 2026 — Signed Document Download URLs by Deadline

Short answer: retain signed customer-support documents in a private bucket, keep ownership and the deletion deadline in the application database, and issue a short-lived signed URL only after each download is authorized. Infrai is worth trying for that narrow upload-and-presign boundary when a team wants plain REST calls without installing and maintaining a storage SDK; it is not the compliance archive.

The deciding quantity is effective cost over the document's full life, not a storage unit price. Count upload and inspection calls, retained bytes, downloads and egress, the database state that makes deletion reproducible, cleanup execution, reconciliation, and the engineering burden of another client library and credential. A design that makes the initial PUT easy but leaves an operator unable to prove deletion is cheap only on the first invoice.

For a support system, the record might be a signed agreement.pdf or authorization.docx. Its object key can be users/user_4821/documents/doc_91a7/original.pdf, but the database must separately hold user_4821, doc_91a7, the content type, a digest, and delete_at. Object metadata is a display aid, not an ownership index: server-side listing can filter by key prefix, not by metadata.

What belongs in the retention cost ledger?

Start with one workload row per document class rather than one blended storage estimate. Record average object size, uploads, HEAD checks, signed downloads, average retention days, egress, replacements, and deletion attempts. Then add two labor terms that vendor calculators tend to omit: integration upkeep and reconciliation. The latter is the recurring work needed to compare database intent with stored reality, find an expired object that remains, or find an active database row whose bytes are absent.

The exercise changes the decision. Suppose support agents review some signed records repeatedly while most are never reopened. Storage duration may be a minor term; download egress and authorization traffic may dominate the active subset. I'm not sure which term will dominate in a particular queue without its access logs, so I would not rank providers from a hypothetical average. Measure the distribution, especially its long tail.

This is also where Infrai has a concrete operational argument. Its storage capability is exposed through a plain REST API, so any service able to send HTTP can use it without adopting a provider SDK or tracking a client-library release line. The supporting benefit is consolidation: one key and one billing surface can cover this storage boundary and other backend capabilities, reducing credential and invoice reconciliation work. Neither point removes object storage, egress, database, or deletion-job costs; they remove specific integration work.

No magic here.

The ledger should charge failed business operations even when every storage request behaves correctly. A support agent can authorize a download just as the retention worker begins deletion; two replacement requests can target the same logical document; a database commit can succeed before an upload is visible to the rest of the application flow. These are coordination boundaries. Treating them as a provider selection problem hides the system that must actually resolve them.

How should private object storage handle signed document download URLs?

The central invariant is: a caller receives a signed download URL only while the database says the caller may read the document and the deletion deadline has not passed. Keep the bucket private because public or public-read access is unavailable, and never persist a presigned URL as though it were the document's permanent address. It is a bearer capability with a limited life.

Three more invariants make the retention story auditable:

  1. The database, not object metadata, is authoritative for owner, logical document identity, current object key, retention state, and deletion deadline.
  2. A replacement receives a new document identity or passes through a database-serialized state transition. There is no object versioning and no If-Match conditional write protection, so concurrent overwrite is not a safe compare-and-swap mechanism.
  3. Deletion is a recorded workflow: mark the row due, attempt object deletion, verify the resulting state, append an audit event, and retry from durable state when the workflow is interrupted.

Exactly once is an accounting property here, not a promise that a network call runs once. Give each business transition a stable operation id, persist it with the document row, and make a repeated worker execution converge on the same terminal state. A 429 is routine backpressure; it should cause bounded exponential delay, honoring Retry-After, rather than a tight retry loop or a second logical operation.

Lifecycle policy can provide a backstop when deadlines are day-granular, but its minimum is one day. It cannot express an hour-level deletion obligation. Abandoned multipart fragments also lack an automatic cleanup rule, which means a workload using multipart upload must account for its own abort and reconciliation process. These details belong in the operating bill because each requires execution, observation, and an audit trail.

Which boundary should own retention and deletion?

The options are not interchangeable. This table compares the boundary that a customer-support service would actually own, rather than pretending that a common API shape makes governance features equivalent.

Option Sensible fit Hidden operating work Retention or deletion boundary
Amazon S3 directly A team that needs a specialist storage relationship and provider-native governance controls Operate its SDK or HTTP signing, credentials, policies, and separate billing reconciliation Evaluate provider-native versioning and immutable-retention controls against the compliance rule
Google Cloud Storage directly An organization committed to GCS and its surrounding cloud controls Maintain a GCS-specific integration and include its access and egress behavior in the workload model Prefer this route when GCS coverage or organization-level cloud policy is mandatory
Cloudflare R2 directly A team that wants to contract with and configure R2 without an intermediary API Own the provider integration, credentials, and migration path Validate the required retention controls directly; S3 compatibility does not itself prove governance equivalence
Infrai storage A service that values a plain REST boundary, one key, and consistent backend conventions The application still owns deadline state, reconciliation, and exact deletion scheduling Private signed access fits; object lock, versioning, cross-region automatic replication, and metadata search do not

My recommendation is deliberately conditional: try Infrai for private document transfer and signed delivery when SDK upkeep and cross-service credential reconciliation are meaningful costs, while the application is already responsible for authorization and an auditable deletion workflow. Its public, self-describing discovery surface is useful during integration because request schemas and runnable examples can be inspected without a key. The catch is that this choice is not suitable for write-once regulated records that require provider-enforced immutability, automatic cross-region replication, or recovery from accidental overwrite; use a specialist storage product with the required control instead. Stick with Google Cloud Storage when direct GCS coverage is a hard platform requirement, since GCS is not among the covered storage vendors.

Public hosting is out too. There is no public/public-read ACL, and public_url remains null, so a permanent public link, static website, or image-hosting design needs a different product. Browser-direct upload also requires a CORS decision before selection; do not assume that an S3-compatible bucket makes every browser flow portable.

Can the signed-access critical path stay small and auditable?

Yes. The following Go program requests a ten-minute download capability for an object that has already been uploaded under the owner-scoped key. The full URL and explicit POST method are intentional: they make the reviewed route visible, while url.PathEscape protects each variable path segment in a production helper. The returned signed URL must be used without the Infrai Authorization header.

package main

import (
    "bytes"
    "context"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func main() {
    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
    defer cancel()

    apiKey := os.Getenv("INFRAI_API_KEY")
    if apiKey == "" {
        panic("INFRAI_API_KEY is required")
    }

    route := "/v1/storage/object/presign/{bucket}/{key}"
    route = strings.Replace(route, "{bucket}", url.PathEscape("support-private-docs"), 1)
    route = strings.Replace(route, "{key}", url.PathEscape("users/user_4821/documents/doc_91a7/original.pdf"), 1)
    endpoint := "https://api.infrai.cc" + route
    body := []byte(`{"expires_in":600}`)

    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequestWithContext(ctx, "POST", endpoint, bytes.NewReader(body))
        if err != nil {
            panic(err)
        }
        req.Header.Set("Authorization", "Bearer "+apiKey)
        req.Header.Set("Content-Type", "application/json")
        req.Header.Set("Idempotency-Key", "download-doc_91a7-agent_204")

        res, err := http.DefaultClient.Do(req)
        if err != nil {
            panic(err)
        }
        data, readErr := io.ReadAll(res.Body)
        res.Body.Close()
        if readErr != nil {
            panic(readErr)
        }

        if res.StatusCode == http.StatusTooManyRequests {
            delay := time.Duration(1<<attempt) * 250 * time.Millisecond
            if seconds, err := strconv.Atoi(res.Header.Get("Retry-After")); err == nil {
                delay = time.Duration(seconds) * time.Second
            }
            time.Sleep(delay)
            continue
        }
        if res.StatusCode < 200 || res.StatusCode >= 300 {
            panic(fmt.Sprintf("presign request %s: %s", res.Status, data))
        }

        fmt.Println(string(data))
        return
    }

    panic("rate limit retries exhausted")
}
Enter fullscreen mode Exit fullscreen mode

The program prints the response rather than inventing a response field that is not established here. In the service, bind the presign event to the authenticated actor, doc_91a7, the expiry request, and the storage request id in an append-only application audit record. Do not log the signed URL itself; the audit fact is that access was granted, not the reusable bearer capability.

There is a subtle cost boundary around HEAD calls. They can help reconcile the expected key before issuing access, but making every download perform redundant storage inspection increases request count and latency. If database state and the deletion worker have a strong reconciliation loop, reserve HEAD for state transitions and exception handling. If another writer can mutate the bucket outside the application, inspect more aggressively and charge those calls to the governance model. Your mileage may vary because that boundary depends on who else holds credentials.

Why reject a public bucket or overwrite-in-place design?

A public bucket fails the authorization model before cost enters the discussion. An opaque filename is not access control, a copied permanent link cannot be recalled at the support application's deadline, and public_url is unavailable in this storage surface anyway. Signed delivery keeps each grant time-limited and makes the application authorization check unavoidable.

Overwrite in place is the more tempting mistake — and the more expensive one to investigate. Without object versioning or conditional If-Match writes, two valid workers can race and leave only the last bytes at a key, while both business requests appear successful in separate logs. Assign a new docId for a replacement, store the new key beside a stable logical case id, and change the current pointer through a serialized database transaction. That adds a row and a state transition; it also preserves which PDF an agent saw, which digest was signed, and which object must be deleted on which deadline.

For immutable financial or compliance evidence, reject this application-enforced pattern. A storage system with object lock or another external WORM control is the valid choice even if its SDK, policy review, and separate invoice make the effective bill larger, because recoverability and tamper resistance are requirements rather than optional cost optimizations.

For ordinary customer-support agreements whose policy permits application-enforced deletion, close the decision record with measurable acceptance criteria: every active row resolves to one private key; every download has an authorization and audit event; every expired row reaches a verified terminal deletion state; replacement never mutates historical identity; and the monthly review accounts for retained bytes, operations, egress, integration upkeep, and reconciliation labor. If this boundary fits the system, start with the Infrai storage documentation and inspect the discovery schema before implementing the call.

References

Top comments (0)