Our engineering design firm has engineering photos that engineers use for designing. Each folder can contain 100+ engineering photos. We would like to know how to implement the best logic for the engineer to download all images (given that there are 100+ photos in the folder) as a zip requesting it from the frontend and sending the folder name to the server to fetch the pictures that belong to that folder name and download them to their local drive i.e desktop or documents folder.
***MY FRONTEND CODE***
const saveImgsBtn = document.getElementById('saveImgsBtn')
saveImgsBtn.addEventListener('click', async()=>{
const folder = {
name: 'IDxyz123_images'
}
const response = await fetch('http://localhost:5000/engineer/design/getImages',{
method:'POST',
body:JSON.stringify(folder),
headers:{
'Content-Type':'application/json'
}
})
let result = await response.json()
})
***MY BACKEND CODE(NODE JS)***
let mainFolderPath = './design_images'
let childFolder = req.body.name
let folderURL = `${mainFolderPath}/${childFolder}`
let folderExists = fs.existsSync(folderURL)
if(folderExists){
res.status(200).json({
message:'Folder exists. Would you like to download images?'
})
//Logic to download images to local drive
}else{
res.status(404).json({
message:'Folder does not exist. Please verify if folder name is correct.'
})
}