satorumurmur / bibi

Bibi | EPUB Reader on your website.
https://bibi.epub.link
MIT License
833 stars 123 forks source link

Loading an epub from a generator script. #109

Open dsancheznet opened 3 years ago

dsancheznet commented 3 years ago

Hello everybody, I am the author of mybrary and I'm happy to announce that I'm working on an integration of bibi into the system as an online epub reader for books stored in the library. I'm having problems loading a book that is streamed by a php script. The script does something like (abbreviated example):

    header('Content-Type: application/epub+zip');
    header("Pragma: no-cache");
    header("Expires: 0");
    echo file_get_contents( $epubData );   

The reason I'm doing it this way is that I do not want to expose the file to unauthenticated users. Doe to this reason, all books and covers are stored in a non public directory, out of reach of the web users. I have been adapting the js files quite heavily to be able to integrate the script into my file structure. As soon as I try to load a book streamed by the downloader script, I get the following error:

image

I am calling the reader in the following manner:

epub.html?book=getbook.php?id%3D1.epub"

Does somebody have a clue on what could be happening? Is it even possible to load en epub this way?

By the way: I'm using PDF.js as well, and it works without flaws calling it this way.

Best regards D.Sánchez

satorumurmur commented 3 years ago

@dsancheznet Thank you for using Bibi. I haven't identified the cause yet, but it's possible that there is a potential problem with Bibi. Can you send me the EPUB file you tried? (Because it can occur with EPUBs which have certain conditions.)

dsancheznet commented 3 years ago

Sending the epub would be no problem, but I don't think that the problem is in BiB/i because when I drop the file locally it opens without any problem. The problem only appears, when the file is to be opened remotely. (Anyway, if you want, please provide me with an email address to send you the file, because it is copyrighted and I can not post it publicly)

Best regards

dsancheznet commented 3 years ago

I think I have found the error!

BiB/i does not examine the header of a file stream, that is why bibi.js was thinking that the file I was trying to load was an unzipped directory structure. After appending &fake=file.epub to the html, everything worked because a valid file ending could be found.

Maybe in the future you want to correct that behaviour.

Best regards D.Sánchez