应用场景:
用于页面中需要下载文件并重复使用,提示用户文件下载路径 方便用户查找
调用方法:
// 创建下载任务
document.addEventListener( "plusready", createDownload, false );
function createDownload() {
var dtask = plus.downloader.createDownload("https://bmfw.jcgov.gov.cn/kindeditor/download?fileId=ff80808175d3f5150175e38c3b946f1b", {}, function(d, status){
// 下载完成
if(status == 200){
console.log("Download success: " + d.filename);//文件在设备中的相对路径
//相对路径转换为绝对路径 可用于安卓提示用户文件保存路径
var path=plus.io.convertLocalFileSystemURL(d.filename);
alert(path);
//文件预览 可自行保存相对路径 在ios设备中下次进入直接预览
plus.runtime.openFile( d.filename );
} else {
console.log("Download failed: " + status);
}
});
//dtask.addEventListener("statechanged", onStateChanged, false);
dtask.start();
}