examples/form/dist/index.js
function download(URL) {
        var convert_to_blob = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

        var request = new XMLHttpRequest();
        var p = new Promise(function (success, fail) {
            request.onload = function () {
                if (request.status === 200) {
                    var blob = request.response;
                    success(blob);
                } else {
                    fail(request);
                }
            };
        });

        request.open('GET', URL, true);
        if (convert_to_blob) {
            request.responseType = 'blob';
        }
        request.send();

        return p;
    }
function download(URL) {
        var convert_to_blob = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

        var request = new XMLHttpRequest();
        var p = new Promise(function (success, fail) {
            request.onload = function () {
                if (request.status === 200) {
                    var blob = request.response;
                    success(blob);
                } else {
                    fail(request);
                }
            };
        });

        request.open('GET', URL, true);
        if (convert_to_blob) {
            request.responseType = 'blob';
        }
        request.send();

        return p;
    }
function download ( URL ) { var convert_to_blob = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : true ; var request = new XMLHttpRequest ( ) ; var p = new Promise ( function ( success , fail ) { request . onload = function ( ) { if ( request . status === 200 ) { var blob = request . response ; success ( blob ) ; } else { fail ( request ) ; } } ; } ) ; request . open ( 'GET' , URL , true ) ; if ( convert_to_blob ) { request . responseType = 'blob' ; } request . send ( ) ; return p ; }
Download file from URL via AJAX and make Blob object or return base64 string if 2nd argument is false
Only files from CORS-enabled domains can be downloaded or AJAX will get security error

@param {String} URL
@param {Boolean} convert_to_blob = true
@returns {Promise}: success(Blob object | base64 string), fail(response XHR object)
Download file from URL via AJAX and make Blob object or return base64 string if 2nd argument is false Only files from CORS - enabled domains can be downloaded or AJAX will get security error