Library for reading file input as chunked for browser context
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.eslintrc
README.md
chunked-file-reader-test.js
chunked-file-reader.js
jasmine.html
package.json
yuidoc.json

README.md

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]);
});