mirror of
https://github.com/koel/koel
synced 2024-12-23 19:13:06 +00:00
12 lines
327 B
TypeScript
12 lines
327 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,
|
|
}
|
|
}
|