我正在尝试从服务器网址下载并保存apk。但我无法下载并保存。你能帮帮我吗?
代码:
onDeviceReady: function() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
app.receivedEvent('deviceready');
myApp.start(); //this is where I put the call to my App's functionality relying on device APIs
}
function gotFS(fileSystem) {
window.fileSystem = fileSystem;
fileSystem.root.getDirectory(window.appRootDirName, {
create: true,
exclusive: false
}, dirReady, fail);
}
function dirReady(entry) {
window.appRootDir = entry;
console.log("application dir is ready");
// alert("ready");
var fileTransfer = new FileTransfer();
var url = "http://www.something.org/Android/Sample.apk";
var filePath = window.appRootDir.toURL() + "Sample.apk";
alert(filePath);
var uri = encodeURI(url.android);
fileTransfer.download(
uri, filePath, function(entry) {
alert("download complete: " + entry.fullPath);
window.plugins.webintent.startActivity({
action: window.plugins.webintent.ACTION_VIEW,
url: 'file://' + entry.fullPath,
type: 'application/vnd.android.package-archive'
},
function(){
console.log("Success");
},
function(e){
alert('Error launching app update');
}
);
}, function(error) {
alert("download error" + error.codename);
});
}
答案 0 :(得分:0)
var canvas = document.getElementById('CanvasId');
var dataUrl =canvas.toDataURL('image/png');