mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
Add common download helper (#628)
* Refactor download functions into a common helper function * Removed unused import
This commit is contained in:
parent
c0d05904b2
commit
9b6fca29e8
4 changed files with 13 additions and 20 deletions
9
src/components/common/download/download.ts
Normal file
9
src/components/common/download/download.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export const download = (data: BlobPart, fileName: string, mimeType: string): void => {
|
||||
const file = new Blob([data], { type: mimeType })
|
||||
const helperElement = document.createElement('a')
|
||||
helperElement.href = URL.createObjectURL(file)
|
||||
helperElement.download = fileName
|
||||
document.body.appendChild(helperElement)
|
||||
helperElement.click()
|
||||
helperElement.remove()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue