Answers for "download file from any url"

0

download file from any url

function download(url, filename) {
fetch(url).then(function(t) {
    return t.blob().then((b)=>{
        var a = document.createElement("a");
        a.href = URL.createObjectURL(b);
        a.setAttribute("download", filename);
        a.click();
    }
    );
});
}

download("https://get.geojs.io/v1/ip/geo.json","geoip.json")
download("data:text/html,HelloWorld!", "helloWorld.txt");
Posted by: Guest on June-08-2021

Code answers related to "download file from any url"

Code answers related to "Javascript"

Browse Popular Code Answers by Language