Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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");
Comment

Download file from url

//
DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
                Uri uri = Uri.parse("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf");
                DownloadManager.Request request = new DownloadManager.Request(uri);
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
                long reference = manager.enqueue(request);
Comment

PREVIOUS NEXT
Code Example
Javascript :: call ajax after ajax 
Javascript :: vue 3 router alias 
Javascript :: middleware 
Javascript :: react does not send the cookie automatically 
Javascript :: get keys length jquery 
Javascript :: react router dom change default path 
Javascript :: es6 features javascript 
Javascript :: array cut only last 5 element 
Javascript :: js join array 
Javascript :: extract value from object javascript 
Javascript :: java script how to not allow soace 
Javascript :: dynamic import in reactjs 
Javascript :: first N elements of an array javascript 
Javascript :: code that will execute at a certain day and time javascript 
Javascript :: js import and export 
Javascript :: get the last array element javascript 
Javascript :: how to check string uppercase or lowersace using regex javascript 
Javascript :: document.queryselector null check 
Javascript :: filter dates javascript 
Javascript :: nextjs api 
Javascript :: remove first and last element from array javascript and seprated by comma 
Javascript :: insert element after element javascript 
Javascript :: Calculator Function JS Javascript 
Javascript :: express js delete request 
Javascript :: lodash reduce 
Javascript :: how to get the current time of a audio in js 
Javascript :: javascript check if string contains only numbers 
Javascript :: node-fetch 
Javascript :: media queries generator script 
Javascript :: javascript copy items into another array 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =