|
1、采用cordova-plugin-http
按照http://docs.wex5.com/cordova-plugin-http/的说明:
- function fileSuccess(data){
- alert("标题:"+data.headers+"\n 状态值:"+data.status+"\n 返回数据:"+data.file);
- }
- //上传下载文件失败返回
- function fileFailure(data){
- alert("\n 状态值:"+data.status+"\n 返回数据:"+data.error);
- }
- Model.prototype.button1Click = function(event){
- cordovaHTTP.downloadFile("http://192.168.0.2:9000/Files/App/2.jpg", {}, {},cordova.file.dataDirectory+"/2.jpg",fileSuccess,fileFailure);
- };
复制代码
真机运行无法下载文件,提示信息标题、状态值都是undefined,哪里不对吗?
2、采用cordova-plugin-fastrde-downloader下载
- Model.prototype.modelLoad = function(event){
- downloader.init({
- folder : "apptest",
- unzip : false,
- check : false
- });
- };
- Model.prototype.button2Click = function(event){
- var fileName = downloader.get("http://192.168.0.2:9000/Files/App/2.zip");
- justep.Util.hint("文件"+fileName + "下载成功");
- };
复制代码
提示下载成功,但是机器里找不到文件,不知道哪里有问题 ?
还有什么下载文件的方式吗? |
|