Reputation: 11
I've been struggling for the past couple hours with trying to unzip a specific .epub file using $cordovaZip but witouth any luck.
The zip and file plugins are installed properly, also $cordovaZip is injected to the specific controller. When i'm trying to unzip a local/remote .epub file I just get the error callback instead of the success one.
Here is a sample of my code.
$cordovaZip
.unzip(
'/templates/test.epub'
cordova.file.dataDirectory).then(function (data) {
console.log('success', data);
}, function (err) {
console.log('error', err);
}, function (progressEvent) {
// https://github.com/MobileChromeApps/zip#usage
console.log(progressEvent);
});
I would appreciate if anyone who encountered the same issue could give me a hand..
Upvotes: 1
Views: 632
Reputation: 4534
You can do it like this:
$cordovaZip.unzip(
'/templates/test.zip',
cordova.file.dataDirectory + extracted_file_name
).then(
function (data) {
console.log('success', data);
}
);
Upvotes: 0
Reputation: 59
I believe an absolute URL is required and not a relative URL. e.g.
var PathToFileInString = cordova.file.externalRootDirectory+"HereIsMyFolder",
PathToResultZip = cordova.file.externalRootDirectory;
JJzip.zip(PathToFileInString, {target:PathToResultZip,name:"SuperZip"},function(data){
/* Wow everiting goes good, but just in case verify data.success*/
},function(error){
/* Wow something goes wrong, check the error.message */
})
Source: https://www.npmjs.com/package/cordova-zip-plugin
Upvotes: 0