UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

21 lines (16 loc) 646 B
export function createObjectURL(fileOrBlob: File | Blob) { const urlCreator = globalThis.URL || globalThis.webkitURL; return urlCreator.createObjectURL(fileOrBlob); } export function downloadBlob(blob: Blob, fileName: string) { const urlCreator = globalThis.URL || globalThis.webkitURL; const blobUrl = urlCreator.createObjectURL(blob); const element = document.createElement('a'); element.setAttribute('href', blobUrl); element.setAttribute('target', '_blank'); element.setAttribute('download', fileName); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); }