Download file with "4 connections" using AJAX?

Asked

Viewed 55 times

1

I’m creating an extension for Google Chrome to speed up file downloading, using various connections. I know that it is possible to post youtube using similar, snagged video file method 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 am open to suggestions using "new Mediasource();".

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.