Last active
August 4, 2022 09:05
-
-
Save rohmanhm/ab05eb68cc344e37cf51f2384d392748 to your computer and use it in GitHub Desktop.
This file contains 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
export function downloadFileFromBlob(fileName: string, blob: Blob) { | |
const url = window?.URL?.createObjectURL(blob); | |
const link = document.createElement("a"); | |
link.style.display = "none"; | |
link.href = url; | |
link.setAttribute("download", fileName); | |
document.body.appendChild(link); | |
link.click(); | |
setTimeout(() => { | |
document.body.removeChild(link); | |
window.URL.revokeObjectURL(url); | |
}, 200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment