Created
June 23, 2022 06:23
-
-
Save daanta-real/af3d247299bc36779114c5d305ff9280 to your computer and use it in GitHub Desktop.
File download function for modern browsers ( = excluding IE)
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
function downloadExecute(downloadURL) { | |
fetch(downloadURL) | |
.then(function(response) { | |
return response.blob(); | |
}).then(function(blob) { | |
var fileBlob = new Blob([blob], {type: blob.type}); | |
var aLink = document.createElement("a"); | |
aLink.href = window.URL.createObjectURL(fileBlob); | |
aLink.download = decodeEntity(pageData.fileName); | |
aLink.click(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment