(id: string, file: File, epub?: Book)
| 59 | } |
| 60 | |
| 61 | export async function addFile(id: string, file: File, epub?: Book) { |
| 62 | db?.files.add({ id, file }) |
| 63 | |
| 64 | if (!epub) { |
| 65 | epub = await fileToEpub(file) |
| 66 | } |
| 67 | |
| 68 | const url = await epub.coverUrl() |
| 69 | const cover = url && (await toDataUrl(url)) |
| 70 | db?.covers.add({ id, cover }) |
| 71 | } |
| 72 | |
| 73 | export function readBlob(fn: (reader: FileReader) => void) { |
| 74 | return new Promise<string>((resolve) => { |