1

我正在开发一个 phonegap 应用程序,它从远程位置下载文件,如下所示:

var remoteFile=url+item.image;
    var localFileName=item.image;

       window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, 
    function onFileSystemSuccess(fileSystem) {
        fileSystem.root.getFile(
        "dummy.html", {create: true, exclusive: false}, 
        function gotFileEntry(fileEntry) {
            var sPath = fileSystem.fullPath.replace("dummy.html","");
            var fileTransfer = new FileTransfer();
            fileEntry.remove();
            fileTransfer.download(
                remoteFile,
                sPath + localFileName,
                function(theFile) {
                    alert("download complete: " + theFile.toURI());
                    showLink(theFile.toURI());
                },
                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);


    function fail(error) {
        alert(error.code);
    }

这会将文件下载到 SD 卡。为了防止外部用户下载文件,我希望应用程序将文件强制存储在设备内部存储中。我有哪些选择?此外,我需要检索文件(图像)并在其他时间点显示相同的内容!

4

0 回答 0