janpio / ionic-epubjs

Ionic 3 app using Epub.js
https://janpio.github.io/ionic-epubjs/
31 stars 20 forks source link

Can't open .epub file downloaded by FileTransfer #49

Open coelhucas opened 6 years ago

coelhucas commented 6 years ago

well, probably it's some noob mistake but after spending some hours trying to fix it I needed to come here.

   this.fileTransfer.download('https://github.com/janpio/ionic-epubjs/raw/master/src/assets/books/moby-dick.epub', path + 'moby-dick.epub').then(entry => {
      this.finishedDownload = true;
      let url = entry.toURL();
      this.current_book = new Book();
      this.current_book.label = "Moby Dick (.epub)";
      this.current_book.file =  path + 'moby-dick.epub';
    })

which is not working. to make it happen I need to use an already existing local path:

    this.current_book = new Book();
    this.current_book.label = "Moby Dick (.epub)";
    this.current_book.file =  "assets/books/moby-dick.epub";

how can I fix it? I've already tried using as the this.current_book.file: entry.toURL(), path + 'moby-dick.epub', only path... anyone knows what can I do?

janpio commented 6 years ago

In your code: What is path? What is url? Why are you setting url and never using it?

coelhucas commented 6 years ago

Sorry for the lack of info. Path is the string where the file are going to be downloaded. url returns the URL where can I locate the file, at first I thought that I can use this url as the current_book.file but it also didn't worked. I was trying to do some adaptation of this: https://www.youtube.com/watch?v=kM4cCQn8Bz4

janpio commented 6 years ago

Is the file actually downloaded ad accessible under that "url"? Can you do other stuff with the file? Can you hardcode a file an use it at https://github.com/janpio/ionic-epubjs/blob/e2cf4dda0d4fa31eb981a490841fcbcfd50c79a0/src/pages/book/book.ts#L34 to see if this can handle files from this source?