Download file with "4 connections" using AJAX?

1

I'm creating an extension for Google Chrome to streamline the file download, using multiple connections. I know that it is possible after youtube uses similar method, grabbing the video file and creating a main buffer.

function load(url, sd)  {
    console.log( url, sd );

    try {
                var httpRequest = new XMLHttpRequest(); 
                httpRequest.open ("GET", url, true);
                httpRequest.responseType = "arraybuffer"; 
                httpRequest.onreadystatechange = function() {

                        if (httpRequest.readyState==4) {
                            if ( codeErro( httpRequest ) ) {

                                try {

                                    var base = new Uint8Array(httpRequest.response);
                                    if(sd.bug > 360 ) {
                                        var base = Frag( base );

                                        if(!base) alert('ERRO BASE' + url );

                                    }
                                    file[i].file = base;
                                }
                                catch(err)  { alert( err ); };

                                if(sd.b) innerB( base, sd.index );

                                var ta = httpRequest.getResponseHeader("Content-Length");
                                size += parseInt(ta);
                                LoadFile(false);

                            } // ------------

                            else LoadFile(true);

                            re--;
                        }

                }; // ;;
            }
            catch(err)  {
                console.log('CATCH httpRequest ERRO', err);
                LoadFile(true);
            }
        }

What I need is to download part of this file with Ajax and the rest I already have ready!

I'm open to suggestions using "new MediaSource ();".

    
asked by anonymous 06.10.2017 / 13:36

0 answers