1.0.3 • Published 6 years ago

checksum-promise v1.0.3

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

checksum-promise

Get checksum of a file in the browser using promises.

Basic usage

Complete documentation of the files can be found here.

First of all you need to include the Checksum class (either via ES6 imports or using CommonJS):

ES6

import Checksum from 'checksum-promise'

CommonJS

const Checksum = require('checksum-promise')

Then, all you need to do is instantiate the class (optionally passing in a config object):

const checksum = new Checksum()

Currently, the only option available in the config is the chunk size you want to divide your file by.

Optional config format:

{
  chunkSize: 10485760
}

10485760 is the default value of the chunk size, therefore if you are ok with using this size, you don't need to supply a config whatsoever.

Finally, you can call the calculateMd5 method of the initialized object:

checksum.calculateMd5(file).then(checksum => {
  // do whatever you need with the checksum
}).catch(error => {
  // in case calculating the checksum failed
})

The provided file should be retrieved from an event on a file input, like so:

function onFileInputChange (event) {
  const file = event.target.files[0]
}

Contributing

In case you want to contribute to this library, create a pull request on our BitBucket, stating what you changed.

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.4

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago