Dev.to WebDev 🛠 Dev 👁 2 📖 6 min read

Cheap Large-File Browser Upload: Multipart, tus, and Direct-to-Object Storage

Use direct-to-object storage for a gaming upload flow, but make retention and deletion the first design decision. Multipart presigned uploads are usually the most controllable path for large browser files; tus is a bette

Use direct-to-object storage for a gaming upload flow, but make retention and deletion the first design decision. Multipart presigned uploads are usually the most controllable path for large browser files; tus is a better fit when pause-and-resume behavior is the product feature. The cheapest transfer path is not the cheapest system if abandoned data survives forever.

This matters for private replays, screenshots, and user-created clips. The browser should send bytes without making the Node.js application a file proxy. The application should own authorization, metadata, retention, and deletion. Storage should own the durable object.

Three words. Measure abandonment.

What should an EU startup compare in cheap large-file browser upload?

The comparison is really about ownership of state. A direct multipart design gives the application an upload ID, numbered parts, and a completion operation. A tus design gives the client a resumable protocol with an offset-oriented upload session. An upload-focused service may hide more of that machinery, which can be valuable when the team needs a working browser experience quickly and does not want to maintain it.

For an EU startup, region selection and data-processing terms come before a spreadsheet of per-request prices. The storage region, backup behavior, deletion contract, access logs, and support obligations should be recorded as acceptance criteria. I'm not sure a generic comparison can answer the residency question for a particular company; the current contract and service documentation have to settle it.

The direct path looks like this:

  1. The authenticated API creates an application upload record.
  2. The API returns short-lived authorization for a fixed object key and a bounded set of parts.
  3. The browser uploads parts directly to storage.
  4. The API verifies the received part list, completes the object, and marks the record complete.
  5. A separate retention worker deletes expired records and their objects.

That separation keeps game traffic away from the web tier. It also makes the difficult parts visible instead of pretending that a file picker is the whole feature.

Where do multipart, tus, and direct-to-object storage fail?

Multipart is a good fit when the team wants explicit control over part size, concurrency, expiry, and provider choice. Its failure mode is an incomplete state machine: a tab closes after uploading seven of ten parts, the database row says uploading, and nobody cleans up the orphaned upload. Retrying completion without an idempotency rule can create a second object or a confusing race.

tus is a good fit when a client may lose connectivity and the user expects a transfer to resume from its last offset. Its trade-off is another protocol and service boundary to operate. The tus server still needs authorization, storage mapping, expiry, and cleanup. A resumable protocol does not solve retention by itself.

An upload-focused service can reduce client work and provide a more finished workflow. The catch is control: custom deletion rules, region requirements, file inspection, or a later storage migration may be harder to express. Stick with a managed upload layer when its lifecycle and data-location guarantees match the product. Move closer to object storage when those guarantees are central to the design.

The browser transport is only half the contract. CORS, content-length limits, object-key rules, and download authorization need tests. A presigned URL should be scoped to one operation and expire; it should not become a reusable public link.

Design retention and deletion before the upload UI

For a private game clip, store a database record such as uploading, ready, expired, or deleted. Keep the logical record even after the object is deleted when the audit trail requires it. Do not infer deletion from a missing thumbnail or from a browser response.

Deletion should be a workflow with retries, not a button that fires one request and forgets. Mark the record as expiring, revoke new downloads, delete the object, and record the result. A retry must be safe. If object deletion is already complete, the next attempt should converge on the same deleted state.

Here is the application-side boundary. The storage adapter is intentionally generic so retention policy remains testable without a live provider.

type UploadState = "uploading" | "ready" | "expired" | "deleted";

type UploadRecord = {
  id: string;
  objectKey: string;
  state: UploadState;
  expiresAt: Date;
};

interface ObjectStore {
  deleteObject(objectKey: string): Promise<void>;
}

async function expireUpload(record: UploadRecord, store: ObjectStore): Promise<UploadRecord> {
  if (record.state === "deleted") return record;

  const now = new Date();
  if (record.expiresAt > now && record.state !== "expired") return record;

  const expiring = { ...record, state: "expired" as const };
  await store.deleteObject(expiring.objectKey);
  return { ...expiring, state: "deleted" };
}

In production, persist the state change around the deletion attempt and retain an error record for retry. The example shows the invariant, not a complete transaction system. That distinction matters: a network timeout does not prove that a deletion failed, so the adapter and job runner need an idempotent contract or a reconciliation pass.

For downloads, the API should check the record state and expiry before issuing a short-lived signed link. A link that was issued yesterday must not keep a deleted clip available today. Cache headers, CDN behavior, and browser history deserve the same review as the object-store policy.

How should you test large browser uploads and expiring download links?

Test the unhappy paths as first-class behavior. Use a fixture large enough to cross several parts, interrupt the browser after a known part, repeat a part, submit parts in a different order, retry completion, and let the upload deadline pass. Then verify the object key, byte count, checksum policy, database state, and cleanup result.

The test matrix should include:

Case Required outcome Signal to record
Part upload is interrupted The session can resume or expires cleanly uploaded parts and age
Completion is retried One logical object and one terminal state idempotency key and result
Download link expires A new authorization check is required denial reason and timestamp
User deletes a clip Reads stop and object deletion converges deletion attempt and final state
Browser sends an oversized part The request is rejected before completion byte count and request ID

Keep the example concrete. A 2 GB replay split into 32 MB parts has 64 expected parts, so a missing part is detectable without inspecting the whole object. The exact size is a test fixture, not a universal recommendation; choose part size after measuring retry cost, browser memory, concurrency, and the storage service's limits.

Metrics should separate coordination latency from byte transfer time. Track time to first part, completion latency, abandoned sessions by age, deletion lag, signed-link denials, and the percentage of sessions that need a retry. A short completion request can hide a bad upload experience if the browser spends minutes retrying a congested part.

A practical decision rule for a gaming upload system

Choose direct multipart when retention policy, object-key control, and storage portability matter more than a polished resumable client. Choose tus when unreliable networks and pause-and-resume interaction are core user requirements and the team will operate its protocol endpoint. Choose an upload-focused service when reducing implementation surface is worth giving up some lifecycle control.

Do not pick from a price table alone. Add storage bytes, request volume, transfer or egress, cleanup workers, observability, support, and engineering time to the estimate. Your mileage may vary by region and traffic shape, especially when players download popular clips repeatedly.

The decision is sound only after a deletion drill. Upload a private fixture, issue a temporary link, expire the record, delete it, retry the worker, and confirm that the old link cannot retrieve the object. If that sequence is vague, the upload architecture is not ready for player data.

References

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.