Large Uploads That Survive Interruptions: Chunks, Limits, Hashes

Large Uploads That Survive Interruptions: Chunks, Limits, Hashes
Technical Specifications & Compatibility
Chunk Size 4 MB to 16 MB per block in most web uploaders
Session State Token plus confirmed byte offset; lost when the tab closes
Broken Pipe Error net::ERR_INCOMPLETE_CHUNKED_ENCODING on truncated responses
Compression Gain 60-90% on text with zstd -19; under 1% on MP4 or JPEG
Item Limits Counted separately from total size, often per folder
Table of Contents

A single 40 GB file takes hours to move over a domestic fibre line, and most of that time is spent waiting on a transfer that a closed laptop lid can destroy. The failure is rarely the network. It is a client that keeps the upload state inside a tab instead of on disk. Understanding how the transfer is split into pieces, where that state lives, and how to prove the bytes arrived separates an upload that survives interruptions from one that starts over.

How a chunked upload is actually assembled

Large files are not posted in one request. The client asks the server for an upload session, receives an identifier and a chunk size, then sends the file as numbered blocks — 4 MB, 8 MB or 16 MB are the usual values. Each block is acknowledged before the next is accepted, and the server stages it under the session identifier rather than in your folder. Only when the final chunk arrives does the client call the completion endpoint; the server then concatenates the object, computes its own digest and promotes it to a real file.

The practical consequence is that the unit of retry is the chunk, not the file. A drop at 87 per cent costs one block, not ninety minutes. The detail that makes this work is idempotency: a block sent twice must not be written twice, so clients tag each chunk with an offset or index. Resuming therefore needs the session token plus the confirmed byte count — the file alone is not enough.

Resumability belongs to the server session, not to your file. When the session identifier is lost, the staged blocks become orphaned data and the upload restarts from zero even though every byte is already sitting on the provider's disk.

Why closing the tab erases the progress bar

A browser uploader holds three things in memory: the file handle, the confirmed byte offset and the session identifier. The handle can be recovered; the other two cannot be guessed. Closing the tab discards the JavaScript heap, and unless the client wrote the offset and token to IndexedDB or localStorage, the next visit opens a new session at offset zero.

This is why "resume" usually works inside a session but not across a restart. Desktop sync clients keep a small state database for exactly this reason; the browser has no durable store it trusts for multi-gigabyte bookkeeping. Two habits follow: leave the tab open, and stop the machine from sleeping. A suspended laptop suspends the socket, and a connection that stays suspended past the server's idle timeout is dead on wake.

The progress bar also lies in a specific way. It normally reports bytes handed to the network stack, not bytes acknowledged, so it can sit at 99 per cent while the last chunk is retried or while the server hashes the assembled object. Two minutes at 99 per cent is verification work; twenty minutes is a dead session.

Compression: when it saves the upload and when it wastes it

Compression trades your CPU against wire time. For logs, CSV exports, source trees, SQL dumps and uncompressed audio, zstd or 7z can strip 60 to 90 per cent of the payload and finish the transfer in a fraction of the time.

It is counterproductive when the payload is already entropy-coded. MP4, JPEG, PNG, HEIC, FLAC and most installers are compressed at the source; zip -9 produces an archive within a fraction of a per cent of the original while burning minutes of CPU. Worse, it destroys resume granularity. A 9 GB archive must be re-sent whole when the client has no chunk state, whereas the original folder could go file by file with failures contained to single items.

PayloadCompress first?Why
Logs, CSV, SQL dumps, sourceYes, zstd -1960–90 % smaller, real time saved
WAV, TIFF, uncompressed videoYesNo entropy coding yet applied
MP4, JPEG, PNG, FLAC, PDF with imagesNoAlready compressed; gains under 1 %
Encrypted containersNoCiphertext is incompressible by design
One 9 GB archive vs a folderPrefer the folderFailure costs one file, not the archive

Compression also changes what you verify. A ZIP rebuilt on another machine can differ byte for byte while holding identical files. Compare the extracted tree, not the container.

Directory depth and the limits nobody quotes

Deep trees fail for reasons unrelated to bytes. Path length comes first: Windows refuses paths beyond 260 characters unless long paths are enabled, so a tree five levels deep with long names can fail because the client could not enumerate it, not because the server rejected it. Per-request overhead comes second: 4,000 files of 20 KB mean 4,000 metadata operations, and the console stalls while it builds the skeleton.

Providers enforce two independent ceilings — maximum object size and maximum item count, sometimes per folder. A folder of 30,000 photos can hit the item limit at 40 GB while a single 200 GB archive passes without complaint.

When a tree runs deeper than four or five levels, flatten it before uploading. A scheme such as project/year/month/ with a README at the root survives being moved, shared and restored far better than a faithful copy of a developer's working directory.

Proving that what landed is what you sent

Never trust the green check. Compute a digest before the upload and again after the download, on the same machine, with the same algorithm.

  1. Generate a manifest in the source folder: find . -type f -print0 | xargs -0 sha256sum > SHA256SUMS.
  2. Upload the folder, then download one or two files back from the provider.
  3. Verify with sha256sum -c SHA256SUMS on Linux or Get-FileHash in PowerShell on Windows.
  4. Compare against any digest the provider publishes; a mismatch means truncation, not a bad local file.

Size alone proves little. Content-Length and the on-disk size can agree while the content differs, because a truncated chunk and a padded chunk both produce plausible numbers. The checksum verifier computes SHA-256, SHA-1 and MD5 in the browser when you cannot install command-line tools, and it catches a silent corruption before you delete the local copy. Pair it with the repair procedure in damaged archive recovery when the digest fails and the source is an archive.

A transfer is finished when a digest matches, not when the progress bar disappears.

Troubleshooting Common Issues

Error / Issue Technical Cause Step-by-Step Fix
net::ERR_INCOMPLETE_CHUNKED_ENCODING The server closed the response before the last chunk arrived, or a proxy rewrote Content-Length. Retry on a wired connection, disable the proxy, and split the batch into smaller folders.
Upload stalls at 99% and never completes Server-side hashing or virus scan of the assembled object, or a session token that expired. Wait two minutes. If it does not finish, reload and upload that file alone.
HTTP 413 Request Entity Too Large The object exceeds the per-file ceiling of the endpoint, which is not the same as your quota. Split with 7z volumes or use the chunked path instead of a single POST.

Frequently Asked Questions

Can a browser upload resume after the tab is closed?

Almost never. The session token and byte offset live in memory, so closing the tab discards them and the next attempt starts at zero. Desktop sync clients keep that state in a local database, which is why they resume and browsers do not.

Should I compress files before uploading them to the cloud?

Compress text, logs, SQL dumps and uncompressed media. Do not compress MP4, JPEG, PNG or FLAC: they are already entropy-coded, gains stay under one per cent, and you lose the ability to retry a single item after a failure.

Why does a folder of photos fail when a bigger archive succeeds?

Item count and total size are separate limits. Some APIs cap the number of objects per folder, so 30,000 small photos can fail where one large archive passes. Check both ceilings before building a large tree.

How do I know the uploaded file is identical to the local one?

Compare a SHA-256 digest of both copies. Run sha256sum on Linux, Get-FileHash on Windows, or use a browser checksum tool. Matching sizes prove nothing on their own.

Related Technical Guides