タイトルが言うように: jquery mobile を使用して phonegap に複数のファイルをダウンロードする方法はありますか?
たとえば、リンクをクリックしてホール リポジトリをダウンロードしますか?
これは、Phone gap FILE API ファイル転送オブジェクトを使用して行うことができます。
複数のファイルをダウンロードする場合は、ループでファイル転送を使用できます。または、ダウンロード ファイルが zip 形式の場合は、ファイル転送と抽出 zip プラグインを使用すると簡単です。
方法1>
サンプル ファイル転送コード:
構成された Zip プラグインは、このコードを適用します
function download(remoteFile)
{
var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/') + 1);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
fileSystem.root.getFile(localFileName, { create: true, exclusive: false }, function (fileEntry) {
var localPath = fileEntry.fullPath;
console.log("localPath1:" + localPath);
if (device.platform === "Android" && localPath.indexOf("file://") === 0) {
localPath = localPath.substring(7);
}
console.log("localPath2 save:" + localPath);
console.log("thid is localFileName :"+localFileName);
extractFile(localFileName); //No need for other formated file except zip file.
var ft = new FileTransfer();
ft.download(remoteFile,
localPath, function (entry) {
console.log("file path:" + entry.fullPath);
var linkopen = document.getElementById("openlink");
linkopen.style.display = "block";
linkopen.href = entry.fullPath;
var zippath = entry.fullPath;
console.log(zippath);
$("#btnExtract").show();
}, fail);
}, fail);
}, fail);
console.log("completed");
}
※ここでは、Zipfile を考慮してこのコードを書きます。コードを変更する必要があります。
方法 2 : 削除
extractFile(localFileName);
コードから