Short answer: use private object storage behind an application authorization check, issue short-lived signed URLs only after that check, and make retention a recorded policy enforced by an idempotent scheduled job. For a marketplace storing model-training artifacts, this is usually simpler to operate than serving every byte through the application, while keeping the app—not possession of an object key—in charge of access.

The important choice is not “which bucket is easiest?” It is where authorization lives. Direct delivery reduces application bandwidth and operational load, but a signed URL temporarily becomes a bearer credential. Proxy delivery keeps a live policy check on every download, but it puts large files, range requests, and retry behavior back on the application path. Pick that boundary first; then compare storage services.

Code the artifact lifecycle before storage setup

I've been paged for missed scheduled work and duplicate delivery. Those incidents changed how I review storage cleanup: a timer is a trigger, not proof that a retention policy was applied. If deleting a marketplace training artifact depends on one cron invocation arriving at exactly the right minute, the design has already confused scheduling with correctness.

The invariant I want is plain: every artifact has an immutable tenant owner, a lifecycle state, and a deletion deadline derived from a versioned retention policy. An upload begins in pending; verification promotes it to active; expiration moves it to deleting; successful object removal moves it to deleted. The database record remains long enough to explain what happened. A retry may repeat the same transition, but it must not extend the deadline or delete an artifact belonging to another tenant. This matters in a marketplace because training runs and seller accounts do not share one lifetime: a seller can revoke access before an artifact reaches its retention deadline, a model build can finish while its source bundle still needs an audit window, and an account deletion request can impose a different path. “Delete files after N days” sounds like one rule, yet it is really policy precedence plus evidence that the winning rule ran. Keep the object key opaque and scoped, for example tenant/<tenant-id>/artifact/<artifact-id>. Do not use an uploaded filename as authority. The filename is display metadata; the tenant and artifact records decide who may act. Likewise, do not treat a successful upload as an active artifact until the application has verified the expected object and committed the state change. This closes the awkward gap where a database row exists but the upload never completes—or bytes exist with no durable owner record.

The deadline wins.

A cleanup worker should claim a bounded batch, compare the stored policy version, and perform deletion idempotently. A second worker seeing deleting can resume rather than invent a new deadline. A missed schedule is then delayed work, visible as backlog age, instead of silent policy drift. Duplicate execution is boring. Good.

How can a startup app give user-uploaded documents private access with signed URLs?

Use a control plane and a data plane. The application is the control plane: it authenticates the caller, loads the tenant and artifact, evaluates revocation and retention state, and asks the object store for a narrowly scoped signed URL. The object store is the data plane: it accepts or returns bytes after validating that temporary credential. The browser never receives a permanent storage credential, and the storage bucket is not public.

The authorization order is easy to get wrong. Sign only after checking ownership and state. Never sign a caller-supplied object key and then ask whether the caller was allowed to name it; resolve the key from the authorized database record. Bind the operation, object, and expiry. For downloads, set response metadata deliberately so a document is downloaded with a safe filename rather than interpreted unexpectedly by the browser. Content-Disposition defines inline and attachment, along with filename parameters, but filename handling still deserves sanitization at the application boundary.

Here is the preventative path I want to see in review. The storage signer is an interface, so the access rule does not depend on a particular S3-compatible implementation.

package artifacts import ( "context" "errors" "fmt" "strings" "time" ) var ErrNotFound = errors.New("artifact not found") type Artifact struct { ID string TenantID string ObjectKey string Filename string State string ExpiresAt time.Time } type Repository interface { FindArtifact(ctx context.Context, artifactID string) (Artifact, error) } type DownloadSigner interface { SignDownload(ctx context.Context, objectKey, disposition string, ttl time.Duration) (string, error) } type Service struct { repo Repository signer DownloadSigner now func() time.Time } func (s Service) DownloadURL(ctx context.Context, tenantID, artifactID string) (string, error) { a, err := s.repo.FindArtifact(ctx, artifactID) if err != nil { return "", err } // Return the same public result for a missing artifact and a tenant mismatch. if a.TenantID != tenantID || a.State != "active" || !s.now().Before(a.ExpiresAt) { return "", ErrNotFound } name := safeFilename(a.Filename) disposition := fmt.Sprintf(`attachment; filename="%s"`, name) return s.signer.SignDownload(ctx, a.ObjectKey, disposition, 10*time.Minute) } func safeFilename(name string) string { name = strings.ReplaceAll(name, `"`, "") name = strings.ReplaceAll(name, "\r", "") name = strings.ReplaceAll(name, "\n", "") if name == "" { return "artifact.bin" } return name } 

The ten-minute lifetime is an example policy, not a universal constant. Choose it from the expected artifact size, client retry behavior, and the damage window after revocation. A URL that expires too quickly creates partial-download failures; one that lives too long weakens revocation. I'm not sure there is a useful default across mobile clients, office networks, and multi-gigabyte training bundles. Measure completion time by size class, then set and review the policy explicitly.

Upload signing follows the same shape but needs a separate operation and a server-chosen object key. Record the intended content constraints before signing. After the client reports completion, verify the upload before changing the artifact to active. A signed upload URL should never double as proof that the bytes arrived or that they are safe to consume.

Compare the three delivery paths

There are three reasonable delivery patterns. None wins everywhere.

Pattern Authorization point Operational consequence Prefer it when
Short-lived signed download Before URL issuance Storage handles byte delivery; access can continue until URL expiry Large artifacts and ordinary per-object access rules
Application proxy On each request through the app The app owns bandwidth, range behavior, and connection load Every read needs a current policy decision or transformation
Isolated distribution service At a dedicated delivery boundary More infrastructure, but separate scaling and audit controls Delivery is important enough to deserve its own failure domain

For an early startup app, the first pattern is often the smallest operational surface. The catch is the bearer window. It is not suitable when policy requires immediate revocation of an already issued link, when each byte range needs a fresh entitlement decision, or when documents must be transformed in flight. Use an application proxy in those cases. Move to a dedicated distribution service when proxy traffic competes with marketplace transactions or when the delivery team needs independent rollout and audit controls.

S3 compatibility can reduce coupling at the request layer, but it is not a complete portability guarantee. Authentication details, lifecycle configuration, event behavior, and consistency assumptions still belong in acceptance tests. Treat AWS S3, Backblaze B2, Cloudflare R2, and self-hosted S3-compatible systems as candidates to test against the same contract, not as interchangeable labels. A shortlist should be judged on private-bucket defaults, signed-operation support, lifecycle controls, audit evidence, regional constraints, egress behavior, and the team's ability to diagnose a failed request. Pricing belongs in that comparison, but it should not outrank access semantics or recovery work.

The simplest option is the one whose failure modes your on-call engineer can distinguish at 03:00. “Download failed” is not a diagnosis. You need to tell authorization denial from expired credentials, missing objects, client cancellation, and policy-driven deletion without logging a signed URL or leaking an object key into a user-visible error.

Roll out retention as a controlled change

Put the policy calculation in ordinary code and test it independently from the scheduler. Given the same creation time, artifact class, tenant policy, and policy version, it should produce the same deletion deadline. Store that result. If the business later changes the retention period, decide explicitly whether existing artifacts keep their recorded deadline or migrate under a controlled job; recalculating silently during every cleanup pass makes an audit impossible to reproduce.

Deployment should start in observation mode. Query eligible artifacts, emit counts and oldest-backlog age, but do not delete. Compare those candidates with known training runs and legal holds. Then enable small batches with a concurrency limit. Watch claim latency, deletion attempts, completed transitions, retry count, and the age of the oldest eligible record. Alert on policy lag, not merely on whether cron fired, because a green scheduler with a permanently failing backlog is still a broken retention system.

The deletion operation needs a durable idempotency boundary. Claim the artifact with a conditional state transition, delete the exact stored key, and record completion. If the process stops after object deletion but before recording deleted, the retry should accept an already-absent object as the expected outcome for that same artifact. It must not broaden the key prefix, recalculate ownership, or select a replacement object. This is where postmortems tend to become painfully specific: a convenient wildcard or mutable filename can turn one retry into a cross-tenant event.

No wildcard.

Test the ugly timing. Run two workers against one eligible record. Revoke a seller while a URL is outstanding. Advance the clock across the deadline. Retry after the object is gone. Confirm that a tenant mismatch and an unknown artifact reveal the same public information. Finally, restore the metadata database and prove that its recorded keys and policy versions still explain the object inventory. Backups that cannot reconstruct ownership are just a second pile of bytes.

This design is more machinery than a public bucket, and it should be. It is also more machinery than proxying a few tiny files from one application instance. Stick with the proxy when the workload is small, downloads require immediate authorization, and the team can absorb the bandwidth path. For larger immutable artifacts with ordinary revocation needs, private object storage plus authorization-before-signing keeps the access decision legible and the delivery path narrow. The retention worker then closes the lifecycle with evidence, retries, and a deadline that does not depend on one perfect cron tick.

References