Library for uploading large files chunked
This is a library containing a collection of utilities for uploading large files.
The main utilities are:
prepareFile(): Will read a supplied file and create a list of chunks from it. Each chunk will be provided with a SHA-1 checksum. The function is working asynchroneously, as it might take a long time, depending on the size of the file and the browser the user is using. An
EventEmitteris returned which will emit different usefull events during the whole process.
upload(): Will consume the list of chunks generated by
prepareFile()and transfer each chunk to the backend. Will provide each chunk with a transfer status. This function also returns an
EventEmitterwhich will emit relevant events during the transfer.
This is a library project which can not be started. It can be builded, tested and linted.
Before doing anything else it is neccessary to install all needed dependencies like so:
user@machine:~/project/$ npm install
user@machine:~/project/$ npm run build
Code coverage and testing
You can run all the tests and get a coverage result by simply running the following:
user@machine:~/project/$ npm test
Multiple browsers are supported. Just set your
BROWSER environment variable accordingly:
- PhantomJS (For headless testing)
In order to test in one or more of them,
just set the
BROWSER environment variable to comma-seperated list like this:
user@machine:~/project/$ BROWSER=Chrome,Firefox npm test
In order to lint your code with tslint run:
user@machine:~/project/$ npm run lint