2013-07-03 110 views
1

我正在尋找一個phonegap 2.3插件,可以解壓縮該文件夾。我發現this plugin at phonegap official repositry 但它只能在phonegap 1.3工作而且它解壓只有一半的文件我有一個zip文件夾包含50 60個html文件。但它只提取5到10個文件並返回「IO錯誤」。請幫我找到的Android的PhoneGap的2.3解壓插件或更高解鎖android中phonegap 2.3或更高版本的插件嗎?

我編輯了這個插件,你也可以從

https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin

+0

發現任何解決方案? –

+0

編輯該插件https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin –

回答

3

[編輯](答案改變)

臨時備用方式下載要做到這一點是通過JavaScript。 這裏的代碼 -

var readFile = function(){ 
    $("#status").html("<br/>"); 
    var url= $("#urlToLoad").val(); 
    var doneReading = function(zip){ 
     extractEntries(zip); 
    }; 

    var zipFile = new ZipFile(url, doneReading); 
}; 


// this function extracts the entries from an instantiated zip 
function extractEntries(zip){ 
    $('#report').accordion('destroy'); 

    // clear 
    $("#report").html(''); 

    var extractCb = function(id) { 
     // this callback is invoked with the entry name, and entry text 
     // in my demo, the text is just injected into an accordion panel. 
     return (function(entryName, entryText){ 
      var content = entryText.replace(new RegExp("\\n", "g"), "<br/>"); 
      $("#"+id).html(content); 
      $("#status").append("extract cb, entry(" + entryName + ") id(" + id + ")<br/>"); 
      $('#report').accordion('destroy'); 
      $('#report').accordion({collapsible:true, active:false}); 
     }); 
    } 

    // for each entry in the zip, extract it. 
    for (var i=0; i<zip.entries.length; i++) { 
     var entry = zip.entries[i]; 

     var entryInfo = "<h4><a>" + entry.name + "</a></h4>\n<div>"; 

     // contrive an id for the entry, make it unique 
     var randomId = "id-"+ Math.floor((Math.random() * 1000000000)); 

     entryInfo += "<span class='inputDiv'><h4>Content:</h4><span id='" + randomId + 
      "'></span></span></div>\n"; 

     // insert the info for one entry as the last child within the report div 
     $("#report").append(entryInfo); 

     // extract asynchronously 
     entry.extract(extractCb(randomId)); 
    } 
} 

附加至Click事件,也可能需要一定時間的較大的zip文件。 它與node.js

+0

感謝讓我試試 –

+0

兄我在1.3中使用了這個插件,但它不工作。我,對於文件夾它的好,但我有100個文件在zip。它不是一個zip文件夾 –

+0

你是針對Android的?或iOS?或每個平臺? – MAST3RMIND

相關問題