Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. function downloadFile(url, filename) {
  2. fetch(url)
  3. .then(resp => resp.blob())
  4. .then(blob => {
  5. const url = window.URL.createObjectURL(blob);
  6. const a = document.createElement('a');
  7. a.style.display = 'none';
  8. a.href = url;
  9. a.download = filename;
  10.  
  11. document.body.appendChild(a);
  12. a.click();
  13. window.URL.revokeObjectURL(url);
  14. })
  15. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement