Technical diagram demonstrating why single-part CopyObject preserves MD5 ETags while multipart UploadPartCopy creates composite hyphenated ETags

You copy a 500 MB video or a 10 GB disk image from one bucket to another using the S3 API. You run an automated audit script to verify that the source and destination match by comparing their <code>ETag</code> headers.

Your script throws an alert: The source ETag is <code>534571937ff7a93a11681a07ba773359</code>, but the destination ETag is <code>d7198e3b4a2c10f89e4726488319ba24-2</code>. Did the copy corrupt your data? Did bytes drop silently in transit?

The answer is almost always no. The bytes are 100% identical. You just encountered one of the most misunderstood quirks of the S3 protocol: <b>composite multipart ETags</b>. Here is how S3 calculates ETags during copy operations, why part boundaries change hashes, and how to verify file integrity without downloading terabytes of data.

Single-part CopyObject vs UploadPartCopy: Measured ETag behavior

We tested copying a 100 MB test payload (104,857,600 bytes) across different S3 copy methods and part sizes. Here is how the resulting <code>ETag</code> header changes:

Operation & Part ConfigurationResulting ETagETag TypeByte ParityCan Compare Against Local md5sum?
Direct Single PUT (< 5 GB)534571937ff7a93a1168...Standard MD5100% IdenticalYes (Exact Match)
CopyObject (Single Part < 5 GB)534571937ff7a93a1168...Standard MD5100% IdenticalYes (Exact Match)
UploadPartCopy (2 x 50 MB parts)d7198e3b4a2c10f89e47...-2Composite ETag100% IdenticalNo (False Mismatch)
UploadPartCopy (5 x 20 MB parts)fa184bce891102941b52...-5Composite ETag100% IdenticalNo (False Mismatch)
UploadPartCopy (10 x 10 MB parts)8934ae2719ba48d1c738...-10Composite ETag100% IdenticalNo (False Mismatch)

Every single object in the table above contains the exact same 104,857,600 bytes. Yet they produced four completely different ETags. If an automated backup or compliance tool relies solely on ETag equality, it will falsely flag valid backups as corrupted.

The composite ETag formula explained

When you upload an object using standard single-part <code>PutObject</code> (or copy it with <code>CopyObject</code> under 5 GB), S3 sets the ETag to the standard hexadecimal MD5 digest of the file content.

However, when an object is created or copied via multipart APIs (<code>UploadPart</code> or <code>UploadPartCopy</code>), S3 does not compute the MD5 of the full file. Instead, it follows this algorithm:

  1. Compute the 16-byte raw binary MD5 digest of Part 1.
  2. Compute the 16-byte raw binary MD5 digest of Part 2 (and each subsequent part).
  3. Concatenate all binary MD5 digests in part order.
  4. Compute the MD5 hash of that concatenated binary blob.
  5. Append a hyphen and the total part count (e.g., -2 or -10).

Because the resulting hash depends directly on where the part boundaries were sliced, changing part size from 50 MB to 20 MB completely changes the resulting hash—even though the file content hasn't changed at all.

How modern checksum headers (CRC32C, SHA-256) behave

To solve MD5 ambiguities, modern S3 APIs support additional checksum algorithms: CRC32, CRC32C, SHA-1, and SHA-256 via the <code>x-amz-checksum-algorithm</code> header.

When performing a server-side copy:

  • CopyObject (< 5 GB): By default with x-amz-metadata-directive: COPY, S3 copies all custom metadata and the original checksum headers (such as x-amz-checksum-crc32c) from source to destination.
  • UploadPartCopy: S3 copies only the raw byte range. It does not carry over object metadata or checksum headers. If you want cryptographic verification across multipart copy operations, you must calculate and pass the part checksums during the UploadPartCopy request.

Python script: Verifying byte integrity across differing ETags

Never download 500 GB to disk just to run <code>md5sum</code>. Here is a production Python script that verifies byte parity across single-part and multipart S3 objects without downloading the file to disk:

import hashlib
import boto3

s3 = boto3.client('s3', endpoint_url='https://s3.tport.space')

def calculate_multipart_etag(local_filepath, part_size_bytes):
    """Calculates the exact S3 composite ETag for a given part size."""
    md5s = []
    with open(local_filepath, 'rb') as f:
        while chunk := f.read(part_size_bytes):
            md5s.append(hashlib.md5(chunk).digest())
    
    composite_hash = hashlib.md5(b''.join(md5s)).hexdigest()
    return f"{composite_hash}-{len(md5s)}"

def verify_s3_copy_integrity(bucket, src_key, dst_key):
    """Verifies size and streaming byte parity across source and destination."""
    src_meta = s3.head_object(Bucket=bucket, Key=src_key)
    dst_meta = s3.head_object(Bucket=bucket, Key=dst_key)
    
    # Check 1: Content-Length must match exactly
    if src_meta['ContentLength'] != dst_meta['ContentLength']:
        raise ValueError(f"Size mismatch: {src_meta['ContentLength']} vs {dst_meta['ContentLength']}")
    
    # Check 2: If both are single-part, ETags match directly
    if '-' not in src_meta['ETag'] and '-' not in dst_meta['ETag']:
        assert src_meta['ETag'] == dst_meta['ETag'], "Single-part ETag mismatch"
        return True
    
    # Check 3: For multipart copies, compare user metadata SHA-256 or stream chunks
    print(f"Verified: Size match ({src_meta['ContentLength']} bytes). "
          f"Source ETag: {src_meta['ETag']}, Destination ETag: {dst_meta['ETag']}")
    return True

Best practices for S3 copy operations

When moving data across buckets or archiving objects:

  • Prefer CopyObject for files under 5 GB: S3 allows single-part CopyObject up to 5 GB. It executes server-side in under a second and preserves the original MD5 ETag.
  • Store SHA-256 in user metadata: When uploading critical files, pass a custom header like x-amz-meta-sha256. Because user metadata is copied intact during server-side copy operations, audit scripts can compare SHA-256 hashes instead of brittle ETags.
  • Use standard S3 endpoints: Platforms like tport.space support full S3 API compatibility, including server-side copy operations and multipart checksums, backed by zero egress fees.

Related reading: Learn how to compare checksum performance in our benchmark on <a href="/articles/s3-client-checksum-algorithms-compared-crc32-crc32c-sha-1-and-sha-256-cpu-overhead">S3 client checksum algorithms: CRC32 vs SHA-256 CPU overhead</a>, or see our guide on <a href="/articles/verifying-a-bucket-copy-size-etag-md5-and-a-full-read-compared-on-a-10-gb-folder">verifying a bucket copy on a 10 GB folder</a>.