Skip to content

Instantly share code, notes, and snippets.

View angstyloop's full-sized avatar

Sean Allen angstyloop

View GitHub Profile
@angstyloop
angstyloop / saveFile.ts
Last active February 23, 2023 06:51 — forked from thomaskonrad/saveFile.ts
Downloading a binary file and saving the file by name in the browser with TypeScript
declare global {
interface Navigator {
msSaveBlob?: (blob: any, defaultName?: string) => boolean
}
}
export default async function saveFile(arrayBuffers: ArrayBuffer[], fileName: string, fileType: string): Promise<void> {
return new Promise((resolve, reject) => {
const blob = new Blob(arrayBuffers, { type: fileType });