[英]Cordova zip plugin not working
I am trying to use cordova zip plugin .I have created a simple cordova project ,added android platform and plugins.Inside index.html, I have simple code as follows: 我正在尝试使用cordova zip插件。我创建了一个简单的cordova项目,添加了android平台和plugins.in index.html,我有简单的代码如下:
<html>
<head>
<!--
Customize this policy to fit your own app's needs. For more guidance, see:
https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
Some notes:
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Zip Plugin to extract files</title>
</head>
<body>
<div class="app">
<h1>Zip Plugin to extract files</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/index.js">
document.addEventListener("deviceready", function(){
$('#zipfile').click(function(e) {
zip.unzip("https://drive.google.com/file/d/0B6zHrNsznc9BUXBVTUE0OE9vY0E/view?ts=569cbb1c", "http://www.google.com",
function(){
console.log('Zip decompressed successfully');
}
);
});
</script>
<button type="file" id="zipfile" name="zipFile"/>
</body>
</html>
Problem : I am not able to invoke the click event handler;also I am sceptical about the code that I have written for unzipping. 问题:我无法调用click事件处理程序;我也对为解压缩而编写的代码表示怀疑。 Please let me know if I am missing any mandatory methods in order to make use of zip plugin.
如果我缺少任何强制性方法以使用zip插件,请告诉我。 I am trying in latest cordova version in Android-23 sdk(win7 machine).
我正在尝试使用Android-23 sdk(win7机器)中的最新cordova版本。
Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks in advance.
提前致谢。
According to the docs, the second argument to unzip is the destination. 根据文档,解压缩的第二个参数是目的地。 You used google.com as a destination, which doesn't make sense.
您使用google.com作为目的地,这没有任何意义。 You want to use a local path instead.
您想改用本地路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.