Use a browser-to-object-storage multipart data path, with a Node.js control plane issuing tenant-bound presigned parts and owning both complete and abort decisions. That separation keeps large product-image bytes away from application servers while preserving the part that matters in a healthtech export: an auditable, idempotent account of which tenant authorized an object, which parts became durable, and which terminal decision was accepted.

The browser is a worker, not the authority. It may retry a failed part, resume a bounded signing window, and report returned part identifiers; it must never choose the object key, tenant, final manifest, or completion state. An S3-compatible multipart upload has an initiation phase, independently uploaded numbered parts, and a completion or abort phase. Completion assembles the object from the submitted part list, while abort stops the multipart upload and releases uploaded parts according to the storage service's behavior.

This ADR chooses windowed presigning, durable upload intent records, and one terminal state transition. It doesn't promise magical exactly-once networking. It makes retries converge on one recorded outcome.

What can a Node.js browser direct multipart upload prove after completion?

Start with four invariants. First, an upload intent belongs to exactly one tenant and one expected object key. Second, every signed part is scoped to one server-created upload identifier and a permitted part number. Third, completion accepts only a canonical manifest whose part numbers are unique and ordered. Fourth, complete and abort race through the same compare-and-set transition, so only one terminal decision becomes authoritative in the application ledger.

The failure boundary is deliberately narrow. The browser can disappear after receiving URLs. A part request can time out even when storage accepted the bytes. The user can open two tabs, and an export job can observe an image while its upload is still pending. None of those events should mutate tenancy or manufacture a second logical image. A retry resends the same part number; reconciliation asks storage or the client for evidence; export selection reads only upload intents in the completed state. Keep the object key opaque and server-derived, for example from a tenant identifier plus a random object identifier. Don't place patient names, diagnoses, email addresses, or original filenames in it. Product imagery may be less sensitive than clinical records, but the export boundary still needs explicit authorization and an audit trail. This design is an engineering control, not a compliance determination; retention, access, and disclosure rules remain properties of the surrounding system. The control record needs more than upload_id and status: record the tenant, object key, declared content type, declared byte length, creation time, expiration policy, terminal decision, actor, request id, and an immutable sequence of state changes. If the system records only the final URL, investigation cannot distinguish a legitimate retry from cross-tenant key substitution. One detail deserves disproportionate attention: an HTTP timeout is an unknown outcome, not proof of failure. Retrying completion with the same idempotency key is safe only if the control plane first reads its own terminal record and treats a previously committed result as the answer. If no terminal result exists, it may reconcile before deciding what to do next. Never translate uncertainty into an automatic abort; completion may already have won.

Export evidence before transfer speed

Multipart upload improves the mechanics of large-file transfer because parts can travel independently, but throughput is governed by the slowest practical layer: the browser's connection budget, part size, signing round trips, storage latency, and memory pressure. More concurrency is not a free multiplier. It can amplify retries, saturate weaker client networks, and make a tenant-scoped export compete with foreground uploads. For tenant-scoped exports, place the image in the export manifest only after the upload intent reaches completed, and freeze the selected object version or immutable object identity in the export job's input. Otherwise a long-running export can read a moving set: some images appear twice after retries, some vanish during cleanup, and some are listed before completion. The export should emit its own audit event containing the tenant, selection boundary, object identities, and result digest, which gives reconciliation a stable comparison point without claiming that every distributed side effect occurred exactly once.

Use a bounded worker pool in the browser and treat its width as a deploy-time policy rather than a universal constant. The control plane can issue a small window of presigned part requests, then renew the window as progress advances. This limits exposed capability, avoids generating thousands of URLs for a transfer that may be abandoned, and gives the service a natural point to recheck tenant authorization. The exact window and part size need measurement on representative devices and networks; I'm not sure a benchmark from one region would predict another deployment, and only workload traces can settle that choice.

S3's multipart documentation sets concrete protocol limits: part numbers range from 1 through 10,000, and parts other than the final part must be at least 5 MiB. Those limits belong in validation at initiation, not in a late completion error. Given a declared size, the server should reject a proposed part plan that cannot fit within the service limit before it creates storage-side state.

Evidence first.

The upload plan as an authorization budget

Pattern Large-file behavior Authority and auditability Valid use case Main limitation
Presign every part at initiation Removes later signing round trips, but creates the full plan before actual progress is known Simple intent record; many unused capabilities may remain valid after abandonment Controlled clients on stable networks with predictable file sizes Coarse cancellation and a larger exposed signing set
Presign a bounded window Adds occasional control-plane calls while keeping bytes direct to storage Authorization can be rechecked between windows; issued part ranges are easy to audit Browser uploads across variable networks and large object sizes Control-plane latency can pause workers if renewal starts too late
Proxy all bytes through the application Application observes every byte and can enforce streaming policy inline Centralized request logs Small uploads or mandatory inline inspection before any storage write Application bandwidth, connection lifetime, and backpressure become the transfer bottleneck
Single presigned upload Minimal state machine One authorization event and one terminal object write Files comfortably inside a tested single-request envelope A late network failure repeats the entire transfer

The selected pattern is the bounded window. The deciding axis is large-file throughput under unreliable browser sessions, but the reason is not raw speed alone: it preserves direct data movement without surrendering authorization checkpoints. The catch is that a signing service now sits on the progress path. It needs low latency, expiration-aware renewal, and enough headroom that workers request the next window before exhausting the current one.

Price should remain a secondary capacity input. Storage providers can differ in storage, download, transaction, and minimum-charge policies; for example, the referenced Backblaze page publishes its current pricing dimensions. Model those dimensions against retained bytes, abandoned parts, export reads, and egress, then verify the current policy at procurement time. A low storage rate cannot compensate for weak cleanup evidence or an export path that retransmits whole objects unnecessarily.

Encoding the terminal decision

The following Go sketch is intentionally storage-neutral. A Node.js service should enforce the same transaction boundaries in its framework and database layer; the language changes, but the state machine does not. Store represents a durable repository, ObjectStore represents the S3-compatible adapter, and audit writes occur in the same database transaction as state changes.

package upload import ( "context" "errors" "sort" ) type State string const ( Pending State = "pending" Completed State = "completed" Aborted State = "aborted" ) type Intent struct { ID, TenantID, ObjectKey, UploadID string State State } type Part struct { Number int ETag string } type ObjectStore interface { PresignPart(context.Context, string, string, int) (string, error) Complete(context.Context, string, string, []Part) error Abort(context.Context, string, string) error } type Store interface { LoadForTenant(context.Context, string, string) (Intent, error) CommitTerminal(context.Context, string, State, string) (bool, error) } func ValidateManifest(parts []Part) error { if len(parts) == 0 { return errors.New("empty part manifest") } sort.Slice(parts, func(i, j int) bool { return parts[i].Number < parts[j].Number }) for i, part := range parts { if part.Number < 1 || part.Number > 10000 || part.ETag == "" { return errors.New("invalid part evidence") } if i > 0 && parts[i-1].Number == part.Number { return errors.New("duplicate part number") } } return nil } func CompleteUpload(ctx context.Context, repo Store, objects ObjectStore, tenantID, intentID, requestID string, parts []Part) error { intent, err := repo.LoadForTenant(ctx, tenantID, intentID) if err != nil { return err } if intent.State == Completed { return nil // Idempotent replay of the recorded terminal result. } if intent.State != Pending { return errors.New("upload is already terminal") } if err := ValidateManifest(parts); err != nil { return err } if err := objects.Complete(ctx, intent.ObjectKey, intent.UploadID, parts); err != nil { return err } committed, err := repo.CommitTerminal(ctx, intent.ID, Completed, requestID) if err != nil { return err } if !committed { return errors.New("terminal decision conflict") } return nil } 

Production code also needs a reconciliation state between the external completion call and the durable terminal commit. That state prevents a process interruption from turning an unknown external outcome into contradictory local history. A reconciler can resolve the attempt using storage evidence and the immutable request record, then commit one terminal result. The example omits transport handlers because route naming is irrelevant to the invariant and tends to obscure the transaction boundary.

Abort follows the same ownership rule: load by tenant, return the existing result for an idempotent replay, reserve the terminal decision, call the storage adapter, and record the audit event. A scheduled sweeper may select expired pending intents, but it must use the same transition rather than deleting rows or issuing an unrecorded storage call. Keep the ledger. Cleanup without evidence is operational debt.

The browser should persist only resumable transfer metadata that is safe for that client context: intent id, upload progress, part numbers, and returned part identifiers. It should send the canonical part manifest to the control plane, never call completion with an object key it invented, and discard presigned URLs after their intended use. Logs should identify the intent and request, not reproduce signed query strings.

Transfer alternatives and the rejected proxy

Proxying the entire image through Node.js was rejected for this healthtech ingestion path because application instances would own long-lived upload connections, byte buffering, and backpressure while also serving authorization and export coordination. That couples horizontal application capacity to media volume and widens the blast radius of a slow client. It is not suitable when the primary decision axis is sustained large-file throughput and the object store can accept direct signed writes.

Stick with the proxy when policy requires synchronous inspection before any byte reaches object storage, when clients cannot use direct storage requests, or when files are small enough that a second data hop is operationally immaterial. Likewise, use a single signed upload when measured file sizes and networks make whole-transfer retries acceptable. Multipart state has a real cost: abandoned uploads require lifecycle cleanup, reconciliation needs an owner, and completion evidence must survive longer than a browser tab.

The decision is therefore conditional. Choose direct multipart transfer when large objects dominate and the team can operate an explicit state machine; choose simpler transfer paths when inspection or low complexity dominates. In either case, tenant ownership, idempotent terminal decisions, and auditable export inputs are the non-negotiable controls.

References