For a cheap large-file browser upload, send multipart data directly to object storage but keep authorization and retention decisions in Node.js. For property-management training artifacts, that split avoids routing every file through the application while preserving tenant checks, expiry evidence, and a useful audit trail.
TL;DR: choose the upload mechanism by who must control the transfer. Use signed multipart operations when the browser can speak the store's object API, a resumable-upload gateway when clients need one stable protocol, or an application-mediated stream when inspection must happen before any byte reaches durable storage. Whichever path you choose, record the same lifecycle events. Upload speed is only half the system.
| Path | Pick it when | Access-control boundary | Delivery trade-off |
|---|---|---|---|
| Signed multipart | A web client can upload parts directly | Node.js authorizes initiation and completion | Few moving parts, but the client understands the storage API |
| Resumable gateway | Several clients need one upload contract | The gateway enforces upload identity and metadata | Stable client protocol, with another service to operate |
| Application stream | Content must be inspected before storage | The application sees every byte | Central policy, but application bandwidth sits in the delivery path |
The table is the decision. The rest of this field guide shows how to make the first path observable without pretending that a successful HTTP request proves retention.
Should a cheap large-file browser upload use multipart storage?
Start with the artifact, not the storage brand. A property-management company may retain a fire-safety recording for a defined training period while restricting it to one property, one course, and a small set of staff roles. The browser needs a convenient delivery path. The organization needs a reproducible answer to three later questions: who authorized this object, when should it expire, and was the policy actually applied?
Cheap can't be the only requirement.
Signed multipart is a strong fit when access can be decided before transfer. Node.js issues short-lived capabilities for a known tenant, object key, and upload session; the browser sends parts; Node.js validates the completion request. The browser never receives general storage credentials. Keep the capability narrow.
Search results often put AWS S3, Cloudflare R2, the tus protocol, and UploadThing beside one another, but they don't occupy one architectural layer. Object stores are destinations, tus defines a resumable transfer protocol, and an upload service can coordinate delivery for an application. Treating those names as a flat price list hides the decision that matters here: does the startup want its browser coupled to an object API through presigned multipart operations, or does it want a separate service boundary to absorb transfer details? The first choice keeps the runtime path short. The second can keep client behavior uniform. Neither choice removes the need for tenant authorization, an intent record, cleanup, and retention verification, so evaluate those controls before comparing delivery convenience.
A resumable gateway fits when delivery simplicity wins. Mobile, browser, and desktop clients can share a single resumable contract, while the gateway translates that contract into durable storage. The operational cost is real: the gateway now needs authentication, capacity planning, logs, and recovery behavior of its own.
Choose an application stream only when policy requires bytes to cross the application boundary first. Examples include synchronous content inspection or a rule that forbids unverified material from entering the durable namespace. It is easy to reason about, yet it turns the Node.js tier into part of the bulk-data plane. Measure backpressure and aborted connections before adopting it.
Make retention data part of authorization
Do not let a browser invent an object key or retention timestamp. Accept business inputs, derive storage metadata server-side, and persist an upload intent before issuing any part capability. This is the crisp before/after: before, an object exists with a filename; after, an intent links tenant, course, policy version, expected size, and expiry.
The example below uses interfaces on purpose. Storage SDK calls differ, but the authorization invariant should survive a provider change.
type UploadRequest = {
tenantId: string;
propertyId: string;
courseId: string;
fileName: string;
contentType: string;
sizeBytes: number;
};
type Actor = {
id: string;
tenantId: string;
permissions: Set<string>;
};
type RetentionPolicy = {
version: string;
retainDays: number;
};
function createUploadIntent(
actor: Actor,
input: UploadRequest,
policy: RetentionPolicy,
now: Date,
) {
if (actor.tenantId !== input.tenantId) throw new Error("tenant_mismatch");
if (!actor.permissions.has("training:upload")) throw new Error("forbidden");
if (!Number.isSafeInteger(input.sizeBytes) || input.sizeBytes <= 0) {
throw new Error("invalid_size");
}
const expiresAt = new Date(now);
expiresAt.setUTCDate(expiresAt.getUTCDate() + policy.retainDays);
const artifactId = crypto.randomUUID();
return {
artifactId,
objectKey: `${input.tenantId}/${input.propertyId}/${artifactId}`,
authorizedBy: actor.id,
expectedSizeBytes: input.sizeBytes,
contentType: input.contentType,
retentionPolicyVersion: policy.version,
expiresAt: expiresAt.toISOString(),
};
}
Persist that return value transactionally as an authorized intent, then ask the storage adapter to begin multipart upload. A safe adapter exposes actions, not credentials:
type PartCapability = {
partNumber: number;
uploadUrl: string;
expiresAt: string;
};
interface MultipartStore {
begin(objectKey: string, contentType: string): Promise<{ uploadId: string }>;
authorizePart(
objectKey: string,
uploadId: string,
partNumber: number,
): Promise<PartCapability>;
complete(
objectKey: string,
uploadId: string,
parts: Array<{ partNumber: number; etag: string }>,
): Promise<{ storedSizeBytes: number }>;
abort(objectKey: string, uploadId: string): Promise<void>;
}
This interface deliberately omits public URLs. Training artifacts remain private; download authorization is a separate decision. It also keeps retention outside the upload protocol. Apply the lifecycle rule through infrastructure configuration, then reconcile that rule against the intent record.
Instrument the state machine, not the progress bar
Picture the system as four boxes in a line: browser, authorization API, object store, and intent database. The browser asks the API for a part capability, sends bytes to storage, then reports completed part identifiers to the API. The API finalizes storage and moves the intent from uploading to stored. A scheduled reconciler compares stored objects and policy state, then records retention_verified or raises an exception.
That diagram-in-words reveals two distinct truths. Transfer telemetry tells you whether bytes moved. Policy telemetry tells you whether the resulting object has the expected owner and expiry. Do not collapse them into one upload_success counter. Use a 5-state intent model such as authorized, uploading, stored, expired, and rejected; state changes should be monotonic except for an explicit administrative correction. A retry may repeat an operation, but it must not manufacture a second artifact record. This concrete split also makes dashboards readable: delivery operators can inspect completion and abort rates, while governance reviewers can inspect objects awaiting retention verification without reverse-engineering transport logs.
Emit structured events at authorization, part-capability issuance, completion, abort, and retention verification. Avoid filenames and signed URLs in logs; both can expose information that does not belong in an operational event. Stable identifiers are enough.
type UploadEvent = {
event: "upload_authorized" | "upload_completed" | "upload_aborted" | "retention_verified";
artifactId: string;
tenantId: string;
policyVersion: string;
durationMs?: number;
sizeBytes?: number;
reason?: string;
};
function emitUploadEvent(event: UploadEvent): void {
process.stdout.write(`${JSON.stringify({ ...event, observedAt: new Date().toISOString() })}\n`);
}
Build metrics from those events: authorized intents, completed uploads, aborted uploads, completion latency, and intents that remain unfinished past their capability window. Alert on symptoms that require action, such as a sustained rise in stale intents or failed retention verification. A single failed browser part is usually a retry signal, not a page.
Short logs win here. They make the ownership boundary obvious.
No guesswork.
Test failure paths before shipping
The happy path proves very little. Test a user from tenant A requesting a capability for tenant B. Test duplicate completion calls, reordered part reports, a missing part, an expired capability, a client disconnect, and an intent whose database write succeeds while storage initiation fails. Each test should assert both state and emitted event.
Completion should be idempotent at your API boundary. Store a completion result against the intent and return it when the same valid request arrives again. Reject a completion whose artifact, upload identifier, or tenant does not match the persisted intent. Never trust the browser's claimed byte count; compare the final stored size with the authorized expectation through the storage adapter.
Cleanup deserves its own test clock. Advance it beyond the authorization window, abort unfinished multipart sessions, and mark the intent expired. Then verify that the cleanup event contains a reason but no capability URL. This catches the quiet failure mode: abandoned parts consume storage while every user-facing request appears healthy.
For deployment, separate schema rollout from behavior rollout. Add intent fields first, deploy writers next, then enable reconciliation and alerts. Watch the count of unknown policy versions. Zero is the target.
Limits of this pattern
Direct delivery cannot inspect bytes before they reach storage. If that is a hard compliance boundary, use an application stream or quarantine namespace and accept the extra operational work. Signed capabilities also shift retry and multipart coordination into the client, so a very thin client may be better served by a resumable gateway.
Retention automation is not proof of deletion by itself. Keep the policy version, verification result, and lifecycle-event history needed by your governance process. The exact evidence requirement belongs to legal and security review, not to an upload library.
Finally, regional placement, data-transfer behavior, multipart limits, and lifecycle semantics vary by storage service and can change. Verify those boundaries in the current primary documentation during evaluation. The durable design choice is the control plane: tenant authorization, immutable intent records, observable state transitions, and tested cleanup.
Top comments (0)