A browser upload becomes a security boundary the moment game evidence contains an account name, a moderation report, or a tournament document. Short answer: let the browser send bytes straight to private object storage with a short-lived, narrowly scoped presigned URL, but let the application choose the object key, record the expected metadata, and authorize every later download.
Do not treat a successful upload as a completed workflow. The storage write and the application state change are separate operations, and retries can duplicate one without repeating the other.
I've been paged by missed scheduled work and duplicate queue delivery. That experience leaves one useful reflex here: make completion idempotent, then make the reconciler boring. A client can close its tab after storage accepts the last byte but before it tells the application. It can also repeat the completion request after a timeout. Both outcomes are normal distributed-system states, not exceptional stories.
Can browser uploads preserve privacy for PDF and DOCX user documents?
Split the path into a control plane and a data plane. The application authenticates the player or tournament operator, decides whether the upload is allowed, selects an opaque object key, records an expected media type and maximum size, and returns a time-limited upload capability. The browser uses that capability to transfer the file directly. The application never proxies the body.
That division keeps large files away from application workers without giving the browser general storage credentials. It also preserves the important ownership decision: a user may request a destination, but cannot choose another tenant's prefix or turn a filename such as ../../appeals/admin.pdf into an authorization decision. The original filename is display metadata. It is not an object key.
Six controls belong in the issue-and-complete flow:
- Authenticate before issuing an upload capability.
- Generate the object key on the server and bind it to the authenticated owner.
- Constrain the accepted size and media type in both application policy and the signed request where the storage interface permits it.
- Use a short expiry and one logical upload session per intended object.
- Keep the bucket private; possession of an object name must not grant a read.
- Complete idempotently, then verify stored metadata before marking the document available.
File extensions are weak evidence. A .pdf name and a browser-supplied content type can help reject obvious mistakes, but neither proves that the bytes are safe. If documents feed a moderation console, add an asynchronous inspection state such as pending_scan; only a successful policy check should move the record to available. Until then, download authorization returns no link.
Cost follows the retry boundary
The awkward window starts after object storage acknowledges the write and ends when the application commits its document record. A direct upload makes that window visible. Hiding it behind an application proxy doesn't remove it; it only moves the same state transition into a longer-running request.
Use a small state machine: issued, uploaded, pending_scan, available, rejected, and expired. Store the upload ID, owner ID, server-generated key, declared byte count, media type, creation time, and a completion idempotency key. A completion request for an already completed upload should return the existing document result. A request whose object metadata differs from the recorded declaration should fail closed, for example with 409 Conflict; a conditional state write can use 412 Precondition Failed when another worker won the transition.
The long-tail case matters. Suppose a 2 GB replay archive finishes, the browser loses its connection before receiving the application's completion response, and a queue consumer receives the same completion message twice. The first consumer verifies metadata and advances the state. The second reads that terminal state and returns success without creating another document or scheduling another scan. If no completion message arrives, a scheduled reconciler lists old issued sessions, checks the exact server-generated key, and either advances a matching object or expires the session. The reconciler must use bounded batches and the same idempotent transition as the request path, because a repair job that invents a second write path will eventually produce a second class of incident.
Quiet is good.
The preventative Go path below keeps product-specific signing behind an interface. The handler owns policy; an adapter owns the storage service's signing format. The example numbers are local policy choices, not universal limits.
package upload import ( "context" "crypto/rand" "encoding/hex" "errors" "fmt" "path/filepath" "strings" "time" ) const maxDocumentBytes int64 = 25 << 20 var allowedTypes = map[string]bool{ "application/pdf": true, "application/vnd.openxmlformats-officedocument.wordprocessingml.document": true, } type Signer interface { SignUpload(ctx context.Context, key, mediaType string, maxBytes int64, expiresAt time.Time) (string, error) } type Sessions interface { Create(ctx context.Context, session Session) error } type Session struct { ID string OwnerID string ObjectKey string MediaType string MaxBytes int64 OriginalName string State string ExpiresAt time.Time } type Request struct { OwnerID string Filename string MediaType string Size int64 } type Response struct { UploadID string URL string Expires time.Time } func Issue(ctx context.Context, signer Signer, sessions Sessions, now time.Time, req Request) (Response, error) { if req.OwnerID == "" || !allowedTypes[req.MediaType] { return Response{}, errors.New("upload is not permitted") } if req.Size <= 0 || req.Size > maxDocumentBytes { return Response{}, fmt.Errorf("size must be between 1 and %d bytes", maxDocumentBytes) } id, err := randomID() if err != nil { return Response{}, err } ext := strings.ToLower(filepath.Ext(req.Filename)) if ext != ".pdf" && ext != ".docx" { return Response{}, errors.New("unsupported filename extension") } expires := now.Add(15 * time.Minute) key := "evidence/" + req.OwnerID + "/" + id session := Session{ ID: id, OwnerID: req.OwnerID, ObjectKey: key, MediaType: req.MediaType, MaxBytes: req.Size, OriginalName: filepath.Base(req.Filename), State: "issued", ExpiresAt: expires, } if err := sessions.Create(ctx, session); err != nil { return Response{}, err } url, err := signer.SignUpload(ctx, key, req.MediaType, req.Size, expires) if err != nil { return Response{}, err } return Response{UploadID: id, URL: url, Expires: expires}, nil } func randomID() (string, error) { b := make([]byte, 16) if _, err := rand.Read(b); err != nil { return "", err } return hex.EncodeToString(b), nil } In production, create the session and capability in an order your cleanup process understands. If signing fails after the session is stored, the session can expire without exposing an object. If the database write fails first, issue no capability. Don't log the returned URL: while it remains valid, it is a credential.
Evaluate single-request and multipart recovery with failure budgets
A single presigned upload is the simplest option when the file fits comfortably inside one request and a retry from byte zero is acceptable. Multipart transfer is for a different operational envelope: large files, unstable client connections, or retry costs high enough that resending completed parts hurts users. It adds state. The application must track a multipart upload identifier, constrain part ownership, list or record completed parts, complete exactly once, and abort abandoned sessions.
| Path | Operational advantage | Main catch | Prefer it when |
|---|---|---|---|
| Application proxy | One place for synchronous inspection and policy | App workers carry every byte and long requests consume capacity | Bytes must be inspected before they may enter storage |
| Direct single request | Few states and a small client | A failed request restarts from byte zero | Documents are bounded and connections are dependable |
| Direct multipart | Completed parts can survive a retry | More session, cleanup, and completion state | Large files or unreliable networks make full retries unacceptable |
Multipart completion deserves the same idempotency rule as document completion. Record the expected upload identifier and object key before issuing part capabilities. Accept part numbers only inside the session's declared range. On completion, verify the returned part set rather than trusting an arbitrary list from the browser. Abort abandoned multipart sessions on a schedule, but never infer ownership from a client-supplied key.
I'm not sure where the right multipart threshold sits for every game or network; your mileage may vary. Resolve it with the actual file-size distribution, mobile failure rate, retry bytes, and support burden. A threshold copied from another system is just folklore.
Implement access control beyond the initial write
Private storage is necessary, but it is not the complete policy. A download endpoint should authenticate the requester, load the document record by an opaque application ID, check tenant and role policy, confirm that the state is available, and only then issue a short-lived read capability for the recorded object key. Never accept a raw object key from a query string and sign it on demand.
Keep audit events around the decisions: upload capability issued, upload completed, inspection result recorded, download authorized, and document deleted. Avoid recording capability URLs or document contents. Useful operational dimensions include state-transition latency, expired-session count, multipart abort count, completion conflicts, inspection backlog age, and denied download count. Alert on symptoms that require action, especially a growing oldest-item age; a raw count often rises simply because traffic rose.
Cross-origin policy is another authorization layer, not the primary one. Permit only the application origins and methods needed by the browser flow, and test the browser's preflight behavior before deployment. A permissive origin rule does not make a leaked capability broader than its signature, but it removes a useful constraint and makes mistakes harder to spot.
There is also a compliance boundary. A storage architecture diagram does not establish regulatory authorization. If a procurement program requires FedRAMP, verify the relevant service, deployment, data flow, and authorization status through the program's official materials; do not infer compliance from API compatibility.
Rollout criteria for keeping an application proxy
Direct-to-storage upload is not suitable when policy requires synchronous inspection before any byte may land in object storage, when clients cannot perform the required signed request, or when every upload must be transformed as part of a single application transaction. In those cases, stick with a bounded proxy or a dedicated ingestion service and pay the capacity cost deliberately.
The catch with presigned access is that the URL is a temporary bearer capability. Keep its scope narrow and expiry short, avoid logs and analytics fields that capture it, and reauthorize downloads rather than handing out permanent links. For highly sensitive evidence, a one-time application-mediated download can be the clearer control even though it adds load.
For the common gaming evidence path, the decision rule is plain: use direct single-request upload for bounded PDF and DOCX documents; graduate large replay or media payloads to multipart only after measurements justify the extra states; retain application proxies where pre-storage inspection is mandatory. In every path, the database record is the authorization source, the storage key is server-generated, and duplicate completion is harmless.

