1.0.4 • Published 7 months ago

s3-etag v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

S3 ETAG

Build, Test & Publish CodeQL

Generate an accurate S3 ETAG in Node.js for any file (including multipart).

Please Note, this only works for unencrypted buckets.

Installation

npm install s3-etag

Usage

import { generateETag } from 's3-etag';

// Simple MD5 hash of contents for non-multipart files
const etag = generateETag(absoluteFilePath);

// MD5 hash of combined contents & part number (see below) for multipart files
const partSizeInBytes = 10 * 1024 * 1024; // 10mb
const etag = generateETag(absoluteFilePath, partSizeInBytes);

How It Works

This is a Node.js implementation of this algorithm.

At a high level:

  • If no partSizeInBytes is specified, return MD5 hash of file contents
  • If partSizeInBytes is specified:
    • Generate parts by comparing partSizeInBytes to the file size
    • Read each part from the file, MD5 hash the part, and append it to a global combined hash
    • Once all parts are processed, generate a new MD5 from the global combined hash, and suffix with the amount of parts

License

See LICENSE.md.

1.0.4

7 months ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago