次のように、リモートの場所からファイルをダウンロードする 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 カードにダウンロードされます。外部ユーザーがファイルをダウンロードできないようにするために、アプリがファイルをデバイスの内部ストレージに強制的に保存するようにします。私のオプションは何ですか?さらに、ファイル (画像) を取得し、別の時点で同じものを表示する必要があります。