feat: add zip downloading

This commit is contained in:
PiratePeep 2025-03-23 16:45:11 -06:00
parent cdae798fcf
commit ab275b5de7
5 changed files with 124 additions and 12 deletions

View file

@ -13,6 +13,33 @@ window.downloadAll = function () {
}, index * 100);
});
};
window.downloadZip = function () {
const jobId = window.location.pathname.split("/").pop();
const userId = document.querySelector("meta[name='user-id']").content;
fetch(`${webroot}/zip/${userId}/${jobId}`, {
method: "GET",
})
.then((res) => {
if (res.ok) {
return res.blob();
}
return Promise.reject(new Error("Failed to download zip"));
})
.then((blob) => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `convertx-${userId}-${jobId}.zip`;
document.body.appendChild(a);
a.click();
a.remove();
})
.catch((err) => console.log(err));
};
const jobId = window.location.pathname.split("/").pop();
const main = document.querySelector("main");
let progressElem = document.querySelector("progress");