Created
May 5, 2020 03:48
-
-
Save darmawan01/7efe35325bec3da8f3c7a0a7abda2778 to your computer and use it in GitHub Desktop.
Create file download link
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
``` | |
download = (data, name) => { | |
const fileURL = window.URL.createObjectURL(data); | |
const tempLink = document.createElement('a'); | |
tempLink.href = fileURL; | |
tempLink.target = '_blank'; | |
tempLink.setAttribute('download', name); | |
tempLink.click(); | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment