Skip to content

Instantly share code, notes, and snippets.

@semlinker
Created July 25, 2022 10:46
Show Gist options
  • Save semlinker/ea97dab1497e8d6f48c7ab67d9c53f04 to your computer and use it in GitHub Desktop.
Save semlinker/ea97dab1497e8d6f48c7ab67d9c53f04 to your computer and use it in GitHub Desktop.
Save File
function saveAs({ name, buffers, mime = "application/octet-stream" }) {
const blob = new Blob([buffers], { type: mime });
const blobUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.download = name || Math.random();
a.href = blobUrl;
a.click();
URL.revokeObjectURL(blob);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment