Download Files on Webは、ファイルをダウンロードする方法と、configure CORS(ブラウザで直接データをダウンロードすることが必須)を示しています。
JSZipは、コンテンツとしての約束をサポートしています。それぞれの非同期ダウンロードを約束することができます。
// raw xhr, fetch, or your favorite ajax library
// just remember, you want:
// - to download **binary** data (jQuery's $.ajax won't work out of the box for example)
// - to return a promise of the content
function downloadUrlAsPromise (url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = "blob";
xhr.onreadystatechange = function(evt) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
resolve(xhr.response);
} else {
reject(new Error("Ajax error for " + url + ": " + xhr.status));
}
}
});
xhr.send();
});
}
// now, we can link firebase and JSZip:
var path = "images/stars.jpg";
var contentP = storageRef.child(path).getDownloadURL().then(downloadUrlAsPromise);
zip.file(path, contentP);
これを把握しましたか?私が現在取り組んでいるウェブサイトでそれを行う必要があります。ありがとう –