mirror of
https://github.com/koel/koel
synced 2024-12-24 11:33:05 +00:00
12 lines
326 B
TypeScript
12 lines
326 B
TypeScript
export const useFileReader = () => {
|
|
const reader = new FileReader()
|
|
|
|
const readAsDataUrl = (file: File, callback: (result: string) => void | Promise<void>) => {
|
|
reader.addEventListener('load', async () => await callback(reader.result as string))
|
|
reader.readAsDataURL(file)
|
|
}
|
|
|
|
return {
|
|
readAsDataUrl
|
|
}
|
|
}
|