Skip to content

Instantly share code, notes, and snippets.

@aron-bordin
Last active January 20, 2016 19:05
Show Gist options
  • Save aron-bordin/324cee008b5931b79ddc to your computer and use it in GitHub Desktop.
Save aron-bordin/324cee008b5931b79ddc to your computer and use it in GitHub Desktop.
Download and open ePubjs with Cordova/Phonegap on Android - http://goo.gl/iW26Dt
download: function(book, uri){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getFile("Book/" + book.file_name, {
create : true,
exclusive : false
}, function(fileEntry) {
localPath = fileEntry.toURL();
ft = new FileTransfer();
ft.download(uri, localPath, function(entry) {
getBook(entry);
}, erroCallback);
},erroCallback);
fileSystem.root.getFile("Book/.nomedia" , {
create : true,
exclusive : false
},
function(fileEntry) {
},
erroCallback);
}, erroCallback);
},
getBook: function(path){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory("Book/BookFolder", {create: true, exclusive:false}, function(fileEntry){
zip.unzip(path.toURL(), fileEntry.toURL(), function(){path.remove(); readBook(fileEntry.toURL());});
});
});
},
readBook: function(path){
//open the epub with the given path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment