chunked-file-reader

Provides a large file reading as chunked

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
chunked-file-reader
0.0.36 years ago6 years agoMinified + gzip package size for chunked-file-reader in KB

Readme

ChunkdFileReader
Reading a large file in the browser context as chunked.

How to Use

var fileElement= document.querySelector('input[type="file"]');
fileElement.addEventListener('change', function(evt){
    // Create object
    var reader= new ChunkdFileReader();

    // Subscribe event listeners
    reader.subscribe('begin', function(evt){
        console.log('Start reading');
    });
    reader.subscribe('progress', function(evt){
        console.log('Progress ' + evt.done + ' / ' + evt.nchunks + ' chunks (' + (evt.done_ratio * 100).toFixed(2) + '%)');
    });
    reader.subscribe('chunk', function(evt){
        console.log('Read chunk: ' + new Uint8Array(evt.chunk));
    });
    reader.subscribe('end', function(evt){
        console.log('Done reading');
    });

    // Read it!
    reader.readChunks(evt.target.files[0]);
});