0

我找到了一个将文件下载到我的设备 sd 卡的功能

application.downloadFile = function(file, callback)
{
    window.requestFileSystem(
    LocalFileSystem.PERSISTENT, 0, 
    function onFileSystemSuccess(fileSystem) {
        fileSystem.root.getFile(
        "dummy.html", {create: true, exclusive: false}, 
        function gotFileEntry(fileEntry) {
        var sPath = fileEntry.fullPath.replace("dummy.html","");
        var fileTransfer = new FileTransfer();
        fileEntry.remove();

        fileTransfer.download(
            application.api+file,
            sPath + "assas.json",
            function(theFile) {
                console.log("download complete: " + theFile.toURI());
                application.dataPath = theFile.toURI();
                callback();
            },
            function(error) {
                console.log("download error source " + error.source);
                console.log("download error target " + error.target);
                console.log("upload error code: " + error.code);
            }
          );
        });
    });
};

该代码工作正常,但它将代码下载到我的 SD 卡中,我想直接在我的应用程序中下载我的文件。

www/datas

但我真的不知道该怎么做。

4

1 回答 1

1

不幸的是 WWW 文件夹是只读的,你不能写入它。您只能写入文件系统。

于 2013-02-16T14:37:22.557 回答