Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
515 B
2
Indexable
Never
function downloadURL(data, fileName) {
    const a = document.createElement('a')
    a.href = data
    a.download = fileName
    document.body.appendChild(a)
    a.style.display = 'none'
    a.click()
    a.remove()
}

function DownloadBlob(data: Uint8Array, fileName: string, mimeType: string) {

    const blob = new Blob([data.buffer], {
        type: mimeType
    })

    const url = window.URL.createObjectURL(blob)

    downloadURL(url, fileName)

    setTimeout(() => window.URL.revokeObjectURL(url), 1000)
}