added new zip download system

This commit is contained in:
averel10
2026-03-20 07:55:36 +01:00
parent c9080f3b3c
commit 815a509f4f
2 changed files with 73 additions and 22 deletions

View File

@@ -24,21 +24,17 @@ export async function downloadFilteredEntriesAsZip(
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || 'Failed to download ZIP');
throw new Error(errorData.error || 'Failed to prepare ZIP');
}
// Get the ZIP blob from response
const blob = await response.blob();
const data = await response.json();
if (!data.success || !data.downloadUrl) {
throw new Error('Invalid response from server');
}
// Trigger download
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `dataset-${datasetId}-export-${new Date().toISOString().split('T')[0]}.zip`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
// Redirect to the generated ZIP file
window.location.href = data.downloadUrl;
} catch (error) {
console.error('Error downloading ZIP:', error);
throw error;