Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function downloadFile(url, filename) {
- fetch(url)
- .then(resp => resp.blob())
- .then(blob => {
- const url = window.URL.createObjectURL(blob);
- const a = document.createElement('a');
- a.style.display = 'none';
- a.href = url;
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- window.URL.revokeObjectURL(url);
- })
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement