Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 16892434/8e892ce4c226260bfeeeb9984ab54240 to your computer and use it in GitHub Desktop.
Save 16892434/8e892ce4c226260bfeeeb9984ab54240 to your computer and use it in GitHub Desktop.
JavaScript: Save a blob to disc
var saveBlob = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (blob, fileName) {
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
saveBlob(file, 'test.zip');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment