项目作者: peak

项目描述 :
Calculate/verify ETag of an S3 object, given a file and chunk size
高级语言: Go
项目地址: git://github.com/peak/s3hash.git
创建时间: 2017-10-25T14:31:42Z
项目社区:https://github.com/peak/s3hash

开源协议:MIT License

下载


MIT License
Tag
godoc
Go Report

s3hash

Calculate/verify hash of an S3 object, given a file and chunk size.

Purpose

Files uploaded to Amazon S3 using the S3 multipart API will have unique ETag values depending on their contents and the chunk size used to upload the file. This package calculates what the ETag will be using local file contents, which is useful for:

  • Comparing local and remote files without downloading them again
  • Verifying an S3 upload by getting the ETag of the uploaded file and comparing it to the one generated locally.

This will work on all types of S3 objects, regardless of whether they’re uploaded using the multipart API or not.

Installation

Using go get:

  1. go get -u github.com/peakgames/s3hash/cmd/s3hash

This will install s3hash in your $GOPATH/bin directory.

Using Homebrew:

  1. brew tap peakgames/s3hash https://github.com/peakgames/s3hash
  2. brew install s3hash

Usage

  1. Usage: s3hash [OPTION]... <chunk size in MB> <file>
  2. -e string
  3. Verify the S3 hash of file
  4. -p int
  5. Use NUM workers to run in parallel (default: number of cores)

Examples

Get hash of local file, to be uploaded to S3 using 15 MB chunks:

  1. $ s3hash 15 filename.gz
  2. adf101740e60ba411adb21d2c50feb64-3

Verify hash of local file

  1. $ s3hash -e adf101740e60ba411adb21d2c50feb64-3 15 filename.gz
  2. OK
  3. (exit code 0)
  4. $ s3hash -e wronghash 15 filename.gz
  5. ERROR
  6. (exit code 1)

Build

To build s3hash manually, clone the repository and use go build:

  1. git clone https://github.com/peakgames/s3hash.git
  2. cd s3hash
  3. go build ./cmd/s3hash

Contributing

Please create an issue and/or a pull request.