[英]Unzip files using zip.js in phonegap
我正在使用phonegap開發android應用,並且還需要從SD卡解壓縮文件(包括.png和.txt文件)。
使用zip.js可以從SD卡讀取zip文件結構,例如文件/目錄列表,但是當我嘗試對zip文件進行充氣並獲取文件內容時,會出現非法的構造函數錯誤。
我已經嘗試了很多次,但是沒有成功。 我怎樣才能做到這一點?
function readZip3()
{
var fullPath = $('#dir_path').val() + "/" + "2151849.zip";
fs.root.getFile(fullPath, {}, function (fileEntry) {
fileEntry.file(function (file) {
var dateBefore = new Date();
zip.createReader(new zip.BlobReader(file), function (zipReader) {
zipReader.getEntries(function (entries) {
alert(entries[28].filename);
entries[28].getData(new zip.BlobWriter(), function (data) {
alert(data);
$('#result').append(data);
zipReader.close(function () {
});
}, function(current, total) {
// onprogress callback
});
});
}, onerror);
var dateAfter = new Date();
$('#time').html(" (parsed in " + (dateAfter - dateBefore) + "ms)");
}, errorHandler);
}, errorHandler);
}
我已通過PR來解決此問題: https : //github.com/gildas-lormeau/zip.js/pull/70
在這里Dupe: 我可以在phonegap中使用zip.js嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.