ai-lab-comic / src /lib /fileToBase64.ts
jbilcke-hf's picture
jbilcke-hf HF staff
add a new experimental feature
421fbba
raw
history blame contribute delete
319 Bytes
export function fileToBase64(file: File | Blob): Promise<string> {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.readAsDataURL(file);
fileReader.onload = () => { resolve(`${fileReader.result}`); };
fileReader.onerror = (error) => { reject(error); };
});
}