Cordova 3.4.0上的FileSystem失败"无法创建目标文件"

Hes*_*ius 5 phonegap-plugins cordova cordova-plugins

我最近将我的iOS Cordova项目从2.7.0升级到3.4.0.

升级后文件系统访问被破坏.(虽然似乎在模拟器中工作?)

我收到一条错误消息,指出"无法创建目标文件",我google了一下,并考虑将我的"完整路径"更改为"toURL()",但无济于事.我真的不知道下一步该尝试什么?

这是我的下载代码

window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,

function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
    "dummy.html", {
    create: true,
    exclusive: false
},

function gotFileEntry(fileEntry) {
    var sPath = fileEntry.toURL().replace("dummy.html", "");
    var fileTransfer = new FileTransfer();
    fileEntry.remove();

    fileTransfer.download(
        "https://dl.dropbox.com/u/13253550/db02.xml",
    sPath + "database.xml",

    function (theFile) {
        console.log("download complete: " + theFile.toURI());
        showLink(theFile.toURI());
        setTimeout(function () {
            checkConnection();
        }, 50);
    },

    function (error) {
        console.log("download error source " + error.source);
        console.log("download error target " + error.target);
        console.log("upload error code: " + error.code);
    });
},
fail);
},
fail);
Run Code Online (Sandbox Code Playgroud)

Hes*_*ius 6

我找到了文件插件(链接)和fileTransfer插件(链接)的文档

在原始问题中进行了更改后,我想知道文件插件部分是否正常,并开始寻找我的fileTransfer代码和提供的示例之间的差异.

结果我没有在我的下载源url(doh)上做encodeURI()

所以完整的,有效的代码:

window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,

function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {
create: true,
exclusive: false
},

function gotFileEntry(fileEntry) {
var sPath = fileEntry.toURL().replace("dummy.html", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
var DBuri = encodeURI("https://dl.dropbox.com/u/13253550/db02.xml");
fileTransfer.download(
    DBuri,
sPath + "database.xml",

function (theFile) {
    console.log("download complete: " + theFile.toURI());
    showLink(theFile.toURI());
    setTimeout(function () {
        checkConnection();
    }, 50);
},

function (error) {
    console.log("download error source " + error.source);
    console.log("download error target " + error.target);
    console.log("upload error code: " + error.code);
});
},
fail);
},
fail);
Run Code Online (Sandbox Code Playgroud)