futurepress / epub.js

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

Getting epub from Content folder (or any folder within site) #645

Open mbowles201 opened 7 years ago

mbowles201 commented 7 years ago

I have an epub file sitting with the other content files (images, css) in an mvc.net application. When I try var Book = ePub({ restore: true, contained: true }); Book.open("/Content/myboook.epub"); Book.renderTo("#BookDisplay");

I get an error of 404 not found and jszip not loaded. The epub is in that directory. When I run your example in my page: `var book = ePub("https://s3.amazonaws.com/moby-dick/", { width: 400, height: 600 });

        book.renderTo("#ePub");`

it works beautifully. First, is your target acutally moby-dick.epub, buy you leave off epub, or does that folder contain all the extracted contents of the epub file? Or does that folder just contain a single epub file. Docs aren't very clear on it, just says "url to epub"

Also, if I host the epub on one of my other sites and map the url, I get a CORS error in javascript.

mbowles201 commented 7 years ago

Solved. Added web config settings for epub mime type and ref to jszip (2.x version as 3.+ is not compatible with epub) and seems to work.

cmroanirgo commented 7 years ago

If you specify a folder, it's assumed that it's an unzipped version of the epub. It's a lot quicker to load this way too (it doesn't download the whole book and then unzip it, but just gets the pages/chapters as it needs them). eg.

/Content/
/Content/META-INF/container.xml
/Content/OPS/content.opf
... etc.

And you'd just specify ePub("/Content/', ...)