diff options
Diffstat (limited to 'apps/web/src/utils/browser.ts')
| -rw-r--r-- | apps/web/src/utils/browser.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/web/src/utils/browser.ts b/apps/web/src/utils/browser.ts index 2b9aa297..cfd3b31b 100644 --- a/apps/web/src/utils/browser.ts +++ b/apps/web/src/utils/browser.ts @@ -1,3 +1,20 @@ +export function downloadBlob({ + blob, + filename, +}: { + blob: Blob; + filename: string; +}): void { + const url = URL.createObjectURL(blob); + const anchor = document.createElement("a"); + anchor.href = url; + anchor.download = filename; + document.body.appendChild(anchor); + anchor.click(); + document.body.removeChild(anchor); + URL.revokeObjectURL(url); +} + export function isTypableDOMElement({ element, }: { |
