Skip to content

Instantly share code, notes, and snippets.

@colelawrence
Created February 10, 2025 22:11
Show Gist options
  • Save colelawrence/943fe88291f9bf2d3a0ee46babd64801 to your computer and use it in GitHub Desktop.
Save colelawrence/943fe88291f9bf2d3a0ee46babd64801 to your computer and use it in GitHub Desktop.
Download a Uint8Array to file
export function downloadFileBinary(filename: string, data: Uint8Array, mimeType = "application/octet-stream") {
const blob = new Blob([data], { type: mimeType });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment