I’m working on a web app that inventories your home items. I’m 90% there except now I need to figure out a way to export photos should the user so chooses. I’ve managed to export the items into a CSV file, but what good is that if they can’t have their photos? I’m currently using MongoDB for the backend, but regardless of how I store them, I need a way where a user clicks a button “Export Photos” and it gets compress into one file for the user to download.
My only concern is what if they’ve stored hundreds of photos?
To avoid blowing out your php process, I’d recommend you dump the files out of MongoDB one by one in a temporary directory on the filesystem, and then use
execcombined withtarorzipto turn it into a compressed archive that you send to the user.Of course this could end up in a pretty bad DDoS of your site, so you’d better write that in a careful way, i.e. if the user has more than 100 images, using a queue with Gearman or some RabbitMQ server might be a good thing, and then you could tell them they will get an email once their archive download link is ready or something? It shouldn’t be a daily thing to export all your pictures I assume, so may be acceptable.