Skip to content

Instantly share code, notes, and snippets.

@rohmanhm
Last active August 4, 2022 09:05
Show Gist options
  • Select an option

  • Save rohmanhm/ab05eb68cc344e37cf51f2384d392748 to your computer and use it in GitHub Desktop.

Select an option

Save rohmanhm/ab05eb68cc344e37cf51f2384d392748 to your computer and use it in GitHub Desktop.

Revisions

  1. rohmanhm renamed this gist Aug 4, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. rohmanhm created this gist Aug 4, 2022.
    13 changes: 13 additions & 0 deletions downloadFileFromBlob
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    export function downloadFileFromBlob(fileName: string, blob: Blob) {
    const url = window?.URL?.createObjectURL(blob);
    const link = document.createElement("a");
    link.style.display = "none";
    link.href = url;
    link.setAttribute("download", fileName);
    document.body.appendChild(link);
    link.click();
    setTimeout(() => {
    document.body.removeChild(link);
    window.URL.revokeObjectURL(url);
    }, 200);
    }