科尔多瓦文件下载问题 [英] Cordova File Download Issue

查看:126
本文介绍了科尔多瓦文件下载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图下载从科尔多瓦应用程序的文件。这是给我的消息作为下载完成,但文件没有保存我的设备上。
下面是code我使用。

  window.requestFileSystem(LocalFileSystem.PERSISTENT,5 * 1024 * 1024,功能(
    FS){
    警报(内部+ fs.root.fullPath);
    警报(cordova.file.dataDirectory);
    警报(fs.root+ fs.root.externalRootDirectory);
    VAR进入= fs.root;
    entry.getDirectory(榜样,{
        创建:真实,
        独家:假的
    },onGetDirectorySuccess,onGetDirectoryFail);
    VAR URI = EN codeURI(http://192.168.15.46/test.pdf);
    VAR英尺=新的文件传输();
    VAR了fileURI = cordova.file.dataDirectory +test21321.pdf
    ft.download(URI,fileURI所,功能(输入){
        警报(下载完成:+ entry.fullPath);
    },功能(错误){
        警报(下载错误+错误code);
    });
});功能onGetDirectorySuccess(DIR){
    警报(创建目录+ dir.name);
}功能onGetDirectoryFail(错误){
    警报(错误创建目录+错误code);
}


解决方案

你是如何决定它是否是您的设备上?如果您尝试通过Windows资源管理器或本机文件系统资源管理器中找到它,你正面临着​​最有可能同样的问题,因为我的here.

基本上,你可以通过尝试读取文件的插件文件,并查看是否有任何数据存储有测试。此外,如果有可用的SD卡,尝试通过改变数据目录就可以了存储

  cordova.file.externalDataDirectory

I am trying to download a file from cordova application. It is giving me message as Download Complete but file is not saved on my device. Below is the code i am using.

window.requestFileSystem(LocalFileSystem.PERSISTENT, 5 * 1024 * 1024, function(
    fs) {
    alert("Inside" + fs.root.fullPath);
    alert(cordova.file.dataDirectory);
    alert("fs.root" + fs.root.externalRootDirectory);
    var entry = fs.root;
    entry.getDirectory("example", {
        create: true,
        exclusive: false
    }, onGetDirectorySuccess, onGetDirectoryFail);
    var uri = encodeURI("http://192.168.15.46/test.pdf");
    var ft = new FileTransfer();
    var fileURI = cordova.file.dataDirectory + "test21321.pdf";
    ft.download(uri, fileURI, function(entry) {
        alert("download complete: " + entry.fullPath);
    }, function(error) {
        alert("download error" + error.code);
    });
});

function onGetDirectorySuccess(dir) {
    alert("Created dir " + dir.name);
}

function onGetDirectoryFail(error) {
    alert("Error creating directory " + error.code);
}   

解决方案

How are you deciding whether it is on your device? If you tried to find it through Windows Explorer or native File system explorer, you are facing most probably the same issue as I here.

Basically you can test that by trying to read the file with File plugin and see if any data is stored there. Also if you have SD card available, try to store on it by changing data directory to be

cordova.file.externalDataDirectory

这篇关于科尔多瓦文件下载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆