I have an application that wants to serve the contents of a series of relatively small ZIP files at a URL in my application but I do not want to unzip the files to some temporary location and serve them from the temporary location. If I have a file called test123.zip
which contains two files hello.png
and world.png
, I want the following URLs to work:
For each request, I will read the ZIP file and extract the requested content and serve it.
There are lots of constraints that make it so extracting once and serving from disk is less than ideal for my application which is a homework grading and annotation system. Users will be uploading 1000's of limited size ZIPs per day and each ZIP might be read 3 times max and each zip will be discarded in 3-4 days. There is strict authorization on who can see each ZIP file and the contents of that ZIP file. That is a lot of churn in some temporary space where I UNZIP and temporarily hold the files. I would rather not build a bunch of infrastructure to do clean up if I don't have to. And I don't want to fill up my temporary space if possible. And this runs in a multi-server load balanced environment and I don't want to go through the effort of making my temporary space an S3 bucket or networked drive...
So, lets leave the assertion that I should not do this out of the answers. I am looking for a library that helps me do this in PHP or even a practice that could handle this. I have already started to write it - I just wish I could use a library instead.