在过去的几个小时里,我一直在努力尝试使用 $cordovaZip 解压缩特定的 .epub 文件,但没有成功。
zip 和文件插件已正确安装,$cordovaZip 也已注入(inject)到特定 Controller 。当我尝试解压缩本地/远程 .epub 文件时,我只是收到错误回调而不是成功回调。
这是我的代码示例。
$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);
});
如果遇到同样问题的人可以帮助我,我将不胜感激。
最佳答案
我认为需要绝对 URL,而不是相对 URL。 例如
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 */
})
关于javascript - ngCordova $cordovaZip 无法解压,Ionic 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34851814/