Created
February 10, 2025 22:11
-
-
Save colelawrence/943fe88291f9bf2d3a0ee46babd64801 to your computer and use it in GitHub Desktop.
Download a Uint8Array to file
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
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