Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 1x 1x 1x 1x 1x | import { FileModel } from '@/shared/@types'
import { extension } from 'mime-types'
export const getFileExtension = (file: FileModel) => extension(file.mimeType)
export const getFileExtensionFromName = (name?: string) => name?.split('.').pop()
export const getFileNameWithoutExtension = (name?: string) => name?.replace(/\.[^.]*$/, '')
export const forceDownload = async (url: string, filename: string) => {
const a = document.createElement('a')
a.download = filename
a.href = url
// For Firefox https://stackoverflow.com/a/32226068
document.body.appendChild(a)
a.click()
a.remove()
return url
}
export const convertBase64ToBlob = (base64: string) =>
new Blob([Buffer.from(base64.split(',')[1], 'base64')], { type: 'image/png' })
|