Cordova的FileTransfer写入错误(代码1)

Yak*_*ako 5 javascript android file-transfer cordova cordova-plugins

我正在使用Cordova 4.2.0 for Android.

我有一些麻烦让FileTransfer插件正常工作.我想有一个写错误

exception:".myApp\/contentImages\/20150110220101.jpg: open failed: ENOENT (No such file or directory)"
Run Code Online (Sandbox Code Playgroud)

filename之前已经过测试,但尚不存在:

rootFS.getFile('.myApp/contentImages/'+file,{create:false},
    function(){
        console.log(file+' already exists');
    },
    function(error){
        console.log(file+" does not exist locally");
        console.log("Error #"+error.code);
        download(file);
    }
);
Run Code Online (Sandbox Code Playgroud)

这是下载功能:

function download (filename){
    var localPath = rootFS.fullPath+'/.myApp/contentImages/'+filename;
    var fileTransfer = new FileTransfer();
    fileTransfer.download(
        encodeURI('http://distantApp/contentImages/'+filename), // This file exists
        localPath,
        function(entry) {
            console.log("download complete: " + entry.fullPath);
        },
        function (error) {
            console.log('download error: ' + error.code + ": "+error.exception+" ; source " + error.source+" ; target " + error.target);
        }
    );
}
Run Code Online (Sandbox Code Playgroud)

可能是什么问题呢?

编辑 代码rootFS

function onDeviceReady(){
    window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, function(){
        console.log("error requesting LocalFileSystem");
    });
}
function gotFS(fileSystem) {
    console.log("got filesystem: "+fileSystem.name); // displays "persistent"
    console.log(fileSystem.root.fullPath); // displays "/"
    window.rootFS = fileSystem.root;
}
Run Code Online (Sandbox Code Playgroud)

Yak*_*ako 12

问题是由Cordova从以前的版本升级引起的.

未正确识别本地文件的路径:.fullPath现在已过时,应替换为.toURL().