【发布时间】:2017-01-05 17:22:44
【问题描述】:
我正在尝试使用ngCordova,但cordova.file.documentsDirectory 属性是null。
我也尝试过将ngCordova 与requestFileSystem 结合使用,但文件仍然没有保存在“下载”中。
我的代码示例:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(directory) {
var fileTransfer = new FileTransfer();
fileTransfer.download(
encodeURI("http://example.com/sample.pdf"),
directory.root.nativeURL + 'sample.pdf',
function(entry) {
console.log("download complete: " + entry.fullPath);
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code" + error.code);
},
false
);
}, function(err){console.error(err)});
谢谢。
【问题讨论】:
标签: javascript android ionic-framework download