解压插件PhoneGap的在Android 2.3或更高? [英] Unzip plugin for phonegap 2.3 or higher in android?

查看:105
本文介绍了解压插件PhoneGap的在Android 2.3或更高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个PhoneGap的2.3插件机器人能解压的文件夹。我发现这个插件在PhoneGap的官方repositry
但它是在PhoneGap的1.3只工作,它仅解压缩文件的一半我有一个包含50 60 HTML文件的zip文件夹。但它只能提取5至10个文件,并返回IO错误。请帮我找到的Andr​​oid的解压缩插件的PhoneGap 2.3或更高版本。

I am searching for a phonegap 2.3 plugin for android which can UnZip the folder . I found this plugin at phonegap official repositry but it is working only in phonegap 1.3 And it is unzipping only half of the file i have a zip folder containing 50 60 html files . but it is extracting only 5 to 10 files and returning "IO error" . Please help me finding a unzip plugin of android for PhoneGap 2.3 or higher

我编这个插件还可以从

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

推荐答案

(答案更改)

临时替代的方式做,这是由JavaScript。
这里的code -

Temporary alternate way to do this is by JavaScript. Here's the code-

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的

Attach this to Click event, also it may take time for large zip files. It works with node.js

这篇关于解压插件PhoneGap的在Android 2.3或更高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆