|
|
|
@ -36,22 +36,19 @@ export function downloadByBase64(buf: string, filename: string, mime?: string, b |
|
|
|
export function downloadByData(data: BlobPart, filename: string, mime?: string, bom?: BlobPart) { |
|
|
|
const blobData = typeof bom !== 'undefined' ? [bom, data] : [data]; |
|
|
|
const blob = new Blob(blobData, { type: mime || 'application/octet-stream' }); |
|
|
|
if (typeof window.navigator.msSaveBlob !== 'undefined') { |
|
|
|
window.navigator.msSaveBlob(blob, filename); |
|
|
|
} else { |
|
|
|
const blobURL = window.URL.createObjectURL(blob); |
|
|
|
const tempLink = document.createElement('a'); |
|
|
|
tempLink.style.display = 'none'; |
|
|
|
tempLink.href = blobURL; |
|
|
|
tempLink.setAttribute('download', filename); |
|
|
|
if (typeof tempLink.download === 'undefined') { |
|
|
|
tempLink.setAttribute('target', '_blank'); |
|
|
|
} |
|
|
|
document.body.appendChild(tempLink); |
|
|
|
tempLink.click(); |
|
|
|
document.body.removeChild(tempLink); |
|
|
|
window.URL.revokeObjectURL(blobURL); |
|
|
|
|
|
|
|
const blobURL = window.URL.createObjectURL(blob); |
|
|
|
const tempLink = document.createElement('a'); |
|
|
|
tempLink.style.display = 'none'; |
|
|
|
tempLink.href = blobURL; |
|
|
|
tempLink.setAttribute('download', filename); |
|
|
|
if (typeof tempLink.download === 'undefined') { |
|
|
|
tempLink.setAttribute('target', '_blank'); |
|
|
|
} |
|
|
|
document.body.appendChild(tempLink); |
|
|
|
tempLink.click(); |
|
|
|
document.body.removeChild(tempLink); |
|
|
|
window.URL.revokeObjectURL(blobURL); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|