mirror of
https://github.com/koel/koel
synced 2024-12-23 11:03:05 +00:00
13 lines
326 B
TypeScript
13 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
|
||
|
}
|
||
|
}
|