Short answer: Large-file throughput changes the easy answer. For a React or Next.js application that accepts avatars and game product images, issue a narrowly scoped presigned upload URL from the application, send the file from the browser to private object storage, and publish it only after a server-side verification step. Keep the web tier out of the byte path.
That last step matters. A successful browser upload means only that an object arrived; it does not mean the object belongs in a profile, catalog, or tenant export. Treat upload, verification, and publication as separate states.
I've been paged by missed jobs and duplicate deliveries. The storage equivalent has the same shape: retries are normal, while an untracked side effect is the incident. The invariant I want is boring and testable — one upload ID can publish at most one logical asset, and a tenant can never choose another tenant's key.
How should a React browser upload product images with a presigned URL to private object storage?
Use a three-step control flow. First, the Next.js server authenticates the user, derives the tenant ID from that identity rather than from a browser-supplied path, and creates an upload ticket containing an opaque object key, an allowed media type, a size ceiling, and an expiration. Second, the React client uploads directly with the exact method and headers covered by the signature. Third, the client reports the opaque upload ID to the application; the application inspects object metadata and changes the database record from pending to ready.
The bucket stays private throughout. The browser receives authority for one operation on one generated key, not bucket credentials and not permission to select an arbitrary key. Reads follow a separate authorization path. For an avatar, that may be a short-lived signed read after checking profile access. For a tenant-scoped product export, it may be an asynchronous job that freezes a manifest of authorized object IDs before streaming or packaging the selected objects.
CORS is part of this design, not a browser afterthought. Allow only the application origins, required upload method, and required request headers. Test the preflight in a production-like environment because a command-line request does not enforce browser CORS. Also keep upload responses out of shared caches; private read responses need an explicit cache policy appropriate to their authorization model.
A practical state machine is pending -> ready -> rejected, with pending -> expired handled by cleanup. Don't let the browser set ready. A 200 or 204 from object storage tells the client that the write completed, but the application still has to verify the expected key, media type, and size.
Resource cost: count bytes, retries, and copies
Throughput is a byte-accounting problem before it is a signing problem. For each candidate path, estimate ingress bytes at the web tier, storage ingress bytes, retry bytes, transformation reads and writes, and export reads. Use the same representative file-size distribution for every option. A proxy makes the application receive and transmit each upload; a signed write removes those upload bytes from application workers; resumable transfer can reduce repeated bytes after a partial network failure, but adds upload-session state. The signer itself handles small control messages, so optimizing its request count while ignoring object traffic measures the wrong system.
Bytes dominate.
Capacity planning also has to include the second copy hidden in the job description. A tenant export reads the accepted product images again and may write a package or stream many objects to a destination. Freeze an authorized manifest before that work starts, cap concurrent reads per tenant, and schedule the export separately from interactive avatar traffic. Measure upload and export queues independently. Otherwise a large export can consume the same storage connections, transformation workers, or network allowance that profile changes need, even though the upload endpoint looks healthy.
Compare proxy, signed PUT, and multipart transfer
The decision is easier to review when the failure budget is explicit:
| Upload path | Best fit | Throughput effect | Main operational cost |
|---|---|---|---|
| Server proxy | Small, controlled uploads | Web tier carries every byte | Body limits, bandwidth, and request timeouts |
| Signed single write | Medium or large objects on stable links | Browser sends bytes straight to storage | CORS, expiry, and verification state |
| Resumable or multipart | Large objects on unreliable links | Retries replace only failed parts | Session state and abandoned-part cleanup |
Access-control failure: tenant authority precedes throughput
The simplest setup is not the one with the fewest endpoints. It is the one with the smallest authority surface and the fewest ambiguous states. Store pending uploads under generated keys such as a random upload ID beneath a server-derived tenant prefix. Do not place an original filename in the authoritative path; keep a sanitized display name as metadata if the product needs it. OWASP recommends allowlisting extensions, validating the actual file type rather than trusting the Content-Type header, generating filenames, limiting size, authorizing uploaders, and scanning files where applicable.
For images, decode the content with a maintained image library during verification. A file signature check alone is weaker than a successful constrained decode, and the browser's media type is only a claim. Enforce pixel and byte limits before any expensive transformation. Keep the original in a non-public pending area until those checks pass, then publish a derived asset or promote the verified object according to the threat model.
The signing implementation is provider-specific. Amazon S3 presigned URLs, Google Cloud Storage signed URLs, and Azure Blob shared access signatures all delegate limited access, but their credential formats and signing rules are different. Put that variation behind a small server-side signer interface. Your domain record should store the opaque object key and upload state, not a signed URL; URLs expire, while asset identity must survive provider changes and export retries.
The browser contract must also say which headers are signed. If the server signs a media type, React must send that exact value. If checksum metadata is required, include it in both the signed request and the upload. I'm not sure a single checksum policy is right for every workload: large product archives, tiny avatars, and transformed images have different CPU and integrity trade-offs. Resolve that choice with a threat model and measurements from representative files, not a hard-coded assumption copied from a sample.
What should the Go admission controller persist?
The control plane can stay small. This Go sketch leaves signing and persistence behind interfaces so provider syntax cannot leak into the tenant model. Authentication middleware supplies the tenant; the request cannot override it.
package upload import ( "context" "crypto/rand" "encoding/hex" "errors" "fmt" "time" ) type Ticket struct { ID string TenantID string ObjectKey string ContentType string MaxBytes int64 State string } type SignedWrite struct { URL string Method string Headers map[string]string ExpiresAt time.Time } type Store interface { InsertPending(context.Context, Ticket) error } type Signer interface { SignPut(context.Context, string, string, int64, time.Duration) (SignedWrite, error) } type Service struct { tickets Store signer Signer } func (s Service) CreateTicket( ctx context.Context, tenantID, contentType string, maxBytes int64, ttl time.Duration, ) (Ticket, SignedWrite, error) { if tenantID == "" { return Ticket{}, SignedWrite{}, errors.New("authenticated tenant required") } if contentType != "image/jpeg" && contentType != "image/png" { return Ticket{}, SignedWrite{}, errors.New("media type not allowed") } if maxBytes <= 0 { return Ticket{}, SignedWrite{}, errors.New("invalid size limit") } id, err := randomID() if err != nil { return Ticket{}, SignedWrite{}, err } key := fmt.Sprintf("pending/%s/%s", tenantID, id) ticket := Ticket{ ID: id, TenantID: tenantID, ObjectKey: key, ContentType: contentType, MaxBytes: maxBytes, State: "pending", } if err := s.tickets.InsertPending(ctx, ticket); err != nil { return Ticket{}, SignedWrite{}, err } signed, err := s.signer.SignPut(ctx, key, contentType, maxBytes, ttl) if err != nil { return Ticket{}, SignedWrite{}, err } return ticket, signed, nil } func randomID() (string, error) { b := make([]byte, 16) if _, err := rand.Read(b); err != nil { return "", err } return hex.EncodeToString(b), nil } There is a deliberate operational detail here: persist pending before returning the signed write. If signing fails after insertion, the reconciler can expire a known record. Returning authority first and trying to record it later creates an object that the control plane may never know exists. The two systems cannot share a transaction, so choose an order with a recoverable orphan and monitor that state.
Completion needs the same discipline. Under a database lock or compare-and-swap, read the ticket by both upload ID and authenticated tenant ID, return the existing asset for ready, reject terminal states, inspect the exact stored key through the storage API, and then commit the asset record and ready transition together. Send transformation or export work through an outbox written in that same database transaction. Queue delivery can repeat. The consumer uses the upload or export ID as its idempotency key.
Test the boundary, not just the happy path: alter one signed header, let a ticket expire, submit a valid image under the wrong tenant, repeat completion concurrently, omit the callback, and retry an export job after its output was already created. Observability should count state age and transition outcomes by reason, without putting signed URLs or credentials in logs. An alert on old pending records is more actionable than an alert on raw request volume.
The incident lesson: callbacks are hints, state is evidence
A duplicate callback should be dull. It may arrive because the browser retried after losing the response, a user double-clicked, or a queue delivered the same completion event again. The completion handler must look up the upload by its server-generated ID, lock or conditionally update its record, and return the already-published asset when the state is ready. It must never create a second asset merely because it received a second request.
Missed work needs a second recovery path. A reconciler can scan old pending records, inspect whether the corresponding object exists, and either resume verification or expire the ticket. This is where the tenant export and avatar flow meet operationally: neither should depend on one browser callback being delivered exactly once. For exports, create the manifest under an idempotency key before scheduling packaging; retries then point to the same manifest and output record.
Be careful with the meaning of failure. A 403 during the browser PUT commonly means the signed request and actual request disagree about authority, expiry, method, or signed headers; it should not trigger an application loop that blindly requests and consumes new tickets. A 413 at an application proxy means the bytes took the proxy path and met its body limit — useful evidence that the architecture did not follow the intended direct path. A verification rejection is different again: retain no public reference, record a reason safe for the user, and let lifecycle cleanup remove the quarantined object.
This is the postmortem test I use: can every transition be replayed, and can an operator explain the current state from durable records without reading application logs? If not, the flow is still request-driven rather than state-driven.
References
- https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- https://www.rfc-editor.org/rfc/rfc9110
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html
- https://cloud.google.com/storage/docs/access-control/signed-urls
- https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview


