Skip to content

Error with .apkg files and anki3 files #2

Description

@HazemE1

This is running on a nextjs server, server action, this is the code to get the error:


export async function generateDeckFromAnkiFile(formData: FormData) {
  const file = formData.get("file") as File;

  readAnkiPackage(file).then((extractedPackage) => {
    const { collection, media } = extractedPackage;

    const decks = collection.getDecks();
    for (const [deckId, deck] of Object.entries(decks)) {
      console.log(deckId, deck.getRawDeck());
      for (const [cardId, card] of Object.entries(deck.getCards())) {
        console.log(cardId, card.getRawCard());
      }
    }

    for (const [name, blob] of Object.entries(media)) {
      console.log(name, blob);
    }
  });
}

⨯ unhandledRejection: Error: Error loading SQLite database
at eval (webpack-internal:///(action-browser)/./node_modules/anki-reader/lib/src/index.js:24:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async readAnkiCollection (webpack-internal:///(action-browser)/./node_modules/anki-reader/lib/src/index.js:17:24)
at async eval (webpack-internal:///(action-browser)/./node_modules/anki-reader/lib/src/index.js:73:28)
at async readAnkiPackage (webpack-internal:///(action-browser)/./node_modules/anki-reader/lib/src/index.js:67:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions