rschroll / efm

Epub for Monocle — A pure javascript implementation of the book data interface for Epub2 and Epub3
http://rschroll.github.com/efm
44 stars 15 forks source link

Can't find variable: FileReader #1

Closed sangari closed 11 years ago

sangari commented 11 years ago

HI,

Parsing is done in firefox browser easily by your code.but when i run your code in safari browser it returns an error as ReferenceError: Can't find variable: FileReader.(sine filereader api is not supported in safari browser)

I am mainly doing my app for ipad.so please help me to overcome this issue in safari by providing some code.Thanks in advance.

rschroll commented 11 years ago

First, it seems that the FileReader API is supported in the newest version of Safari. So the easiest solution would be to upgrade to Safari 6.

If that's not an option, you might be able to work around it. The first argument to the Epub object needs only be a Blob object. Here is a project that provides Blobs to browsers that don't come by them naturally. There's no documentation, unfortunately. If you scroll down this page to "File API", you'll find several projects that implement the HTML File API for those browsers that don't have it. Many of them rely on Flash, though, so they may not work for you.

Note also that you'll need to make some adjustments to make zip.js run on Safari 5.

This answer on Stack Exchange suggests that the best solution is just to send the file to your server and then echo it back. Of course, if you're sending the file to the server, you might as well just unpack it there and send back an appropriate book data object. Then you can avoid EFM completely.

Good luck, and if you figure out a clever work-around, please let me know!

sangari commented 11 years ago

hai, thanks for your reply.i am using safari5.1.2.i want to made to work in ipad can u pls provide me some example code.

I have tried your answer but i failed to get to work in safari.

On Sat, Mar 2, 2013 at 11:25 PM, rschroll notifications@github.com wrote:

First, it seems http://caniuse.com/filereader that the FileReader API is supported in the newest version of Safari. So the easiest solution would be to upgrade to Safari 6.

If that's not an option, you might be able to work around it. The first argument to the Epub object needs only be a Blob object. Herehttps://github.com/eligrey/Blob.jsis a project that provides Blobs to browsers that don't come by them naturally. There's no documentation, unfortunately. If you scroll down this pagehttps://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfillsto "File API", you'll find several projects that implement the HTML File API for those browsers that don't have it. Many of them rely on Flash, though, so they may not work for you.

Note also that you'll need to make some adjustmentshttp://gildas-lormeau.github.com/zip.js/to make zip.js run on Safari 5.

This answer on Stack Exchangehttp://stackoverflow.com/questions/7734150/what-to-use-instead-of-filereader-for-safarisuggests that the best solution is just to send the file to your server and then echo it back. Of course, if you're sending the file to the server, you might as well just unpack it there and send back an appropriate book data object https://github.com/joseph/Monocle/wiki/Book-data-object. Then you can avoid EFM completely.

Good luck, and if you figure out a clever work-around, please let me know!

— Reply to this email directly or view it on GitHubhttps://github.com/rschroll/efm/issues/1#issuecomment-14332177 .

rschroll commented 11 years ago

I have tried your answer but i failed to get to work in safari.

Well, I didn't give you an answer, I gave you three possible routes to an answer.  If you don't tell me which you tried, what worked, and what didn't, I have no hope of helping you further.  My previous reply was a summary of what I found when I googled "FileReader safari" -- I don't have any secret knowledge I'm withholding.

FYI: Your style of questioning (giving little detail and then asking for code) comes off as rather rude.  I'm guessing you're not a native English speaker, so you probably don't intend this.  Nonetheless, you should check out http://www.catb.org/esr/faqs/smart-questions.html

rschroll commented 11 years ago

Closing for lack of response. But anyone interested in this is still welcome to comment.