futurepress / epub.js

Enhanced eBooks in the browser.
http://futurepress.org
Other
6.43k stars 1.1k forks source link

cant open local epub files #956

Open veeyka opened 5 years ago

veeyka commented 5 years ago

hello . its my code `

` when i load this url as epub url https://s3.amazonaws.com/epubjs/books/moby-dick/OPS/package.opf it works completely nice and it show book but when i give path of local host for my .epub file . it shows nothing and no error is in console . same on chrome and firefox . i put my epub file on a host to share http://gamingo.ir/sample.epub thanks
pgaskin commented 5 years ago

Where is the web page and the ebook being stored? Also, if you are loading a .epub file rather than an unpacked epub (.opf), you need the zip libraries added to the page.

fchasen commented 5 years ago

You also might want to try using a local server like https://github.com/indexzero/http-server

kevinhendricks commented 5 years ago

FWIW, I tried the same thing. I ran the spreads.html example on my desktop in many browsers with a url to a local file:// and according to all of them they consider a file: style url to be some sort of cross-site CORS violation. This is with all 3 main browsers I have accesss to: Safari, Chrome, and Firefox.

To recreate, make sure dist exists and has epub.js in it nd that is positioned correctly relative to the examples directory.

Then using any browser navigate to to spreads.html and open it passing along a local file url to an existing epub.

It just hangs. In developer mode you can see a number of error and alerts related to violation of cross-site restrictions. There does not seem to be a way to get around them by changing browser user preferences.

If you let the default external mobi dick url be used instead, all works. But this sort of defeats the whole purpose of using a browser with your epub.js to read you own local epubs.

kevinhendricks commented 5 years ago
Screen Shot 2019-08-29 at 12 13 16 PM
kevinhendricks commented 5 years ago

Here are the errors from the latest Safari attempting to load your example/spreads.html with a relative file url to an opf file. If I use the absolute file:: url I get the exact same issues.

The worst thing is that the page itself just sits there trying to load so unless you had enabled the Developer tools, you would not know why.

I was planning on creating a simple Qt WebEngine based app to create a local e-reader for proofing for Sigil (an epub editor) but this looks to not be easily done given the above.

rhythmone commented 4 years ago

I had the same, and was able to get around it by disabling a bunch of checks at the apache level. It took a couple of days to setup and was very hit/miss. So, to bypass all that again I am now trying to Dockerize the implementation of the epubjs-reader.

veritymedia commented 2 years ago

Old thread, i know. You can use FileReader to feed the file into the book instance. There is an example in the examples folder (input.html I think). Been racking my brain for a while.

aehlke commented 1 year ago

I wrapped epubjs into a SwiftUI app with WKWebView to use a custom epub:// url scheme for viewer and assets (fed in via swift delegate). It's open src WIP if anyone wants it, https://github.com/lake-of-fire/swiftui-webview