P.02 / Integrity utility

S3 ETag Generator

A concurrent hashing utility that validates multipart uploads to Amazon S3 without slowing the workflow down.

What it does

Recomputes the ETag S3 assigns to a multipart upload, in the browser, so a client can verify an upload arrived intact without downloading it again. For a multipart object the ETag is not a hash of the file — it is the MD5 of the concatenated binary MD5s of each part, suffixed with the part count. Reproducing it means splitting the file on exactly the same part boundaries and hashing in the same order.

The implementation slices the file into parts, hashes each with CryptoJS, and holds the raw digests in order while running a bounded number of parts concurrently. Order is preserved by index rather than completion, because the final digest depends on it.

Why it exists

Large uploads fail quietly. A truncated part or a retried chunk produces an object that exists, has a plausible size, and is wrong. Comparing a locally computed ETag against the one S3 returns turns that into a check that runs at upload time, on the client, before anything downstream trusts the file.

Using it

A single TypeScript module, etag.ts, exporting calculateS3ETag(file, partSizeMB, concurrency). The part size must match the one used for the upload or the digest will not agree. GPL-3.0 licensed.

s3-etag-generator ↗