我正在开发一个可以从远程位置下载文件的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卡。为了防止外部用户下载文件,我希望应用程序将文件强制存储在设备内部存储中。我有什么选择? 此外,我需要检索文件(图像)并在其他时间点显示它!