I can’t download files located in a folder in Firebase storage after they reach a certain size, is there any solution to this problem?
async function downloadFilesAsZip(folderPath, zipFilename) {
console.log('Button clicked');
document.getElementById('status').innerText = "please wait...";
const storageRef = storage.ref().child(folderPath);
try {
// List all files in the folder
const fileRefs = await storageRef.listAll();
// Create a new instance of JSZip
const zip = new JSZip();
// Add each file to the zip
await Promise.all(fileRefs.items.map(async (itemRef) => {
const downloadURL = await itemRef.getDownloadURL();
const response = await fetch(downloadURL);
const fileBlob = await response.blob();
zip.file(itemRef.name, fileBlob);
}));
// Generate the zip file asynchronously
const zipBlob = await zip.generateAsync({ type: "blob" });
// Create a download link and trigger download
const downloadLink = document.createElement('a');
downloadLink.href = URL.createObjectURL(zipBlob);
downloadLink.download = zipFilename;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
document.getElementById('status').innerText = "download should start..";
} catch (error) {
console.error('Error fetching or downloading files:', error);
document.getElementById('status').innerText = "Error fetching or downloading files. Check console for details.";
}
}
what are possible solutions ?
1