Access to already downloaded data

I need to upload a large (> 100 MB) data file through XmlHttpRequest. The data is from a third party, and I would like to gradually display the content as it is downloaded.

So, I thought the following would work:

var req = new XMLHttpRequest();
req.open( "GET", mirror.url, true );
req.responseType = "arraybuffer";

req.onload = function( oEvent ) {
    console.log( "DONE" );
};
var current_offset = 0;
req.addEventListener("progress", function(event) {
    if( event.lengthComputable ) {
        var percentComplete = Math.round(event.loaded * 100 / event.total);
    }
    var data = req.response;
    // Fails here: req.response is null till load is called

    var dataView = new DataView( data );
    while( current_offset < dataView.byteLength ) {
        // do work
        ++current_offset;
    }

    console.log( "OFFSET " + current_offset + " [" + percentComplete + "%]" );

}, false);
try {
    req.send( null );
} catch( er ) {
    console.log( er );
}

Unfortunately, according to the specification, .responsenot available.

Is there a way to access already downloaded data without resorting to such horrible workarounds as usage Flash?

EDIT:

Found at least a working custom solution for Firefox:

responseType = "moz-chunked-arraybuffer";

See also: WebKit equivalent to moz-chunked-arraybuffer "xhr responseType

+5
source share
2 answers

, , . . HTTP-: 206 .

, . , , .

WebSockets .

, , , , , -, .

+2

?

100 , PreloadJS .

0

All Articles