使用Cordova解压缩ZIP文件

时间:2018-01-15 20:10:05

标签: android html cordova zip cordova-plugins

我有一个用于android的cordova应用程序,我想解压缩.ZIP文件

要做到这一点,请使用以下代码,除了cordova-plugin-zip cordova插件,但在执行时会向我发送错误和文本:“糟糕,你无法解压缩文件”

myApp.onPageInit('actualizarApp', function (page) {     
  myApp.params.swipePanel = false;  
  processZip(); 
});

var zipSource = "http://127.0.0.1"; // Path of the destination folder 
var destination = "/storage/emulated/0/";



function processZip(){
    // Handle the progress event
    var progressHandler = function(progressEvent){
        var percent =  Math.round((progressEvent.loaded / progressEvent.total) * 100);

        // Display progress in the console : 8% ...
        console.log(percent + "%");
    };

    // Proceed to unzip the file

    window.zip.unzip(zipSource, destination, (status) => {
        if(status == 0){
            console.log("Files succesfully decompressed");
        }

        if(status == -1){
            console.error("Oops, cannot decompress files");
        }
    },progressHandler); }

错误:

 Oops, cannot decompress files 
     window.zip.unzip    @  actualizarApp.js:34
     fail                @  zip.js:24 
     callbackFromNative  @  cordova.js:293
     (anonymous)         @  VM76:1

使用我找到的以下示例: enter link description here

0 个答案:

没有答案