function processZipFile(file) {
zip.createReader(new zip.BlobReader(file), function (reader) {
reader.getEntries(function (entries) {
z = entries;
var infoplist = null, resoucesArsc = null, androidManifest = null;
for (var i = 0; i < entries.length; i++) {
if (entries[i].filename.match(/Payload\/([^\\\?\/\*\|<>:"]+\.app\/)Info\.plist/)) {
infoplist = entries[i];
continue;
}
if (entries[i].filename.match(/AndroidManifest.xml/)) {
androidManifest = entries[i];
continue;
}
if (entries[i].filename.match(/resources.arsc/)) {
resoucesArsc = entries[i];
continue;
}
}
processZipFileSubmit(infoplist, resoucesArsc, androidManifest);
});
}, function (error) {
console.log(error);
alert("读取安装包信息失败!");
});
}
var uploadFileHandle = function (uploadUrl, fd, callbackSuccess, callbackFail) {
var xhr = new XMLHttpRequest();
xhr.open("POST", uploadUrl, true);
xhr.overrideMimeType("application/octet-stream");
xhr.send(fd);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
Common.SuccessHandler($.parseJSON(xhr.responseText), callbackSuccess, callbackFail)
} else {
ErrorHandler(xhr.statusText, 0, callbackFail)
}
}
}
};
function processZipFileSubmit(infoplist, resoucesArsc, androidManifest) {
var url = '/AppParser/getAppInfo';
var data = {};
var sys = null;
var icon = null;
if (infoplist != null) {
data.system = "ios";
infoplist.getData(new zip.BlobWriter(), function (blob) {
//修改处理获取ios数据处理xml
var fd = new FormData();
fd.append('type', 'ipad');
fd.append('upFile', blob);
uploadFileHandle(url, fd, function (result) {
sAppName = result.appName;
iVersion = result.version;
icon = result.icon;
ajaxCallBack(icon);
}, function (errMsg, errCode) {
});
});
} else if (resoucesArsc != null && androidManifest != null) {
data.system = "android";
var fd = new FormData();
androidManifest.getData(new zip.BlobWriter(), function (blob) {
//修改处理
fd.append("upFile",blob)
fd.append('type', 'android');
uploadFileHandle(url, fd, function (result) {
sAppName = result.appName;
iVersion = result.version;
icon = "apk";
ajaxCallBack(icon);
}, function (errMsg, errCode) {
});
});
} else {
alert("上传的文件不正确,无法读取!");
return false;
}
}