Created
December 6, 2022 13:14
-
-
Save Sov3rain/a57ec45e384601fa894e811ff5a71c65 to your computer and use it in GitHub Desktop.
save a blob as a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const blobUrl = URL.createObjectURL(blob); | |
const link = document.createElement('a'); | |
link.href = blobUrl; | |
link.download = fileName; | |
document.body.appendChild(link); | |
// link.click() does not work on the latest Firefox and some modern browsers. | |
link.dispatchEvent( | |
new MouseEvent('click', { | |
bubbles: true, | |
cancelable: true, | |
view: window, | |
}), | |
); | |
document.body.removeChild(link); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment