A presigned upload is usually the right delivery mechanism for browser receipt ingestion, but the cheapest storage choice is the one that preserves an auditable ownership boundary, not the one with the smallest headline number. For a healthtech system, I would issue a short-lived capability for one immutable object, send the browser directly to object storage, and make the backend verify the resulting object before it enters the receipt ledger.
TL;DR: Keep authorization and receipt state in your service; keep byte delivery in object storage. Compare total request, retrieval, retention, and egress behavior for your actual access pattern. A presigned URL reduces delivery work, but it does not prove that a file is valid, complete, or safe to retain.
The upload is a capability, not a verdict.
The decision record
The invariants are narrow and deliberate:
- A receipt has one server-generated object key, and the key is never derived from an untrusted filename.
- The upload capability is bound to that key, an expected content type, a size limit enforced by the storage request, and an expiry.
- The receipt remains
pendinguntil a worker checks object metadata, computes a digest, runs malware and format checks, and records an audit event. - The original bytes are retained as the evidence object; normalized previews are separate derivatives.
That last boundary matters. An HTTP success response proves that a request completed at the transport layer. It does not establish that the payload is the receipt the user intended to submit. Payment and ledger systems teach the same uncomfortable lesson repeatedly: an exactly-once mindset means making state transitions idempotent and observable, not pretending a distributed upload can be exactly once in the physical world.
For the browser path, the options look like this:
| Option | Delivery simplicity | Access control | Audit boundary | Appropriate use |
|---|---|---|---|---|
| Backend proxies bytes | High for the browser | Strong and centralized | Easy to correlate | Small files or strict network policy |
| Short-lived presigned upload | Moderate | Strong if the capability is narrow | Requires post-upload verification | Receipts and other large browser uploads |
| Public or long-lived upload endpoint | High initially | Weak | Difficult to defend | Almost never for original records |
I would choose the middle row for ordinary receipt intake, then spend engineering effort on verification and reconciliation. That is the access-control versus delivery-simplicity trade-off in concrete form.
Which object storage service should handle browser file uploads?
The reader's word “cheapest” hides several different meters. Stored bytes are only one. A useful estimate includes retained original bytes, metadata and request operations, downloads for human review, failed or repeated uploads, derivative generation, and egress to systems outside the storage region. The correct comparison is a small workload model, not a price-page race.
For example, suppose a month contains 80,000 receipts, an average original of 1.8 MB, two review downloads per accepted receipt, and a 30-day retention window before archival policy takes over. Those numbers are planning inputs, not a benchmark. The model should also include a retry factor because mobile browsers disappear between a successful request and the application's final callback. A service with simple delivery but awkward retrieval or lifecycle controls can move cost and operational risk into a later stage.
I keep the selection worksheet intentionally boring: region availability, object immutability controls, lifecycle behavior, request granularity, egress semantics, access-log support, and the quality of its S3-compatible or HTTP interface if interoperability is required. The last item is a boundary, not a guarantee; “compatible” still needs tests for multipart behavior, conditional requests, metadata, and error responses.
How does the critical path preserve control?
The application creates the receipt record before issuing a capability. It never accepts a client-supplied destination, and it does not mark the record complete from a browser callback alone. The following Go sketch shows the shape of that boundary; the storage adapter can target a self-hosted or hosted implementation without changing the receipt state machine.
type Receipt struct { \tID string \tObjectKey string \tStatus string \tDigest string } func StartReceipt(ctx context.Context, userID string, size int64, contentType string) (Receipt, string, error) { \tif size <= 0 || size > 10<<20 { \t\treturn Receipt{}, "", errors.New("receipt size is outside policy") \t} \tif contentType != "application/pdf" && contentType != "image/jpeg" { \t\treturn Receipt{}, "", errors.New("receipt type is outside policy") \t} \treceipt := Receipt{ \t\tID: newID(), \t\tObjectKey: "receipts/" + newID(), \t\tStatus: "pending", \t} \tif err := receiptStore.Insert(ctx, userID, receipt); err != nil { \t\treturn Receipt{}, "", err \t} \turl, err := objectStore.PresignPut(ctx, receipt.ObjectKey, PresignOptions{ \t\tContentType: contentType, \t\tContentLength: size, \t\tExpires: 10 * time.Minute, \t}) \tif err != nil { \t\treturn Receipt{}, "", err \t} \treturn receipt, url, nil } The worker then reads the object through a trusted service identity, verifies the observed length and media signature, calculates a digest, and writes an idempotent verification result. If the same event is delivered twice, the receipt ID and object key remain the same, so the second attempt records no second accounting effect. Audit records should include actor, receipt ID, object key, observed metadata, decision, and timestamp; they should not copy the full receipt into every log line.
Which failure boundary deserves the most attention?
The dangerous gap is between object creation and application state. A user can close the tab after storage accepts the bytes. A callback can be retried. A worker can time out after storing its result but before acknowledging a queue message. None of these conditions justifies deleting the original or promoting it to an accepted receipt without a durable check.
A reconciliation job should periodically compare pending records with object metadata, identify orphaned objects under the controlled prefix, and retry verification with an idempotency key. Give unresolved records a quarantine state with an explicit retention rule. This is less glamorous than a fast upload demo, but it is where auditability is won.
Caching needs the same restraint. Receipt originals should normally be private and served through an authorization check or a separately issued read capability. Cache-Control is a response policy, not an access-control system; its directives describe caching behavior and must be evaluated alongside the authentication and storage policy. The MDN reference documents that distinction and the available directives.
The rejected option, and when it is valid
I would reject a backend proxy as the default for larger browser files because every byte consumes application capacity and makes delivery simplicity compete with request handling. It remains valid for small, highly sensitive documents when a network policy requires all bytes to pass through a controlled service, or when the service must transform the stream before storage. That is a different constraint, not evidence that presigned delivery is universally superior.
The practical decision rule is therefore modest: choose the storage service whose complete workload model and control surface fit the receipt lifecycle, then isolate it behind a storage interface. Keep the authorization decision, receipt status, verification evidence, and audit trail in your application. The object store should be replaceable infrastructure, while the original receipt and the reasons it was accepted or rejected remain accountable records.
References
- MDN, “Cache-Control header”: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
- IETF, RFC 9110, “HTTP Semantics”: https://www.rfc-editor.org/rfc/rfc9110
- IETF, RFC 6749, “The OAuth 2.0 Authorization Framework”: https://www.rfc-editor.org/rfc/rfc6749