I’ve been interested in Crystal for a while, and am finally using it for a project at work! We have a virtual filesystem in the database but are storing the files in Wasabi (basically S3). The project is to create and stream a zip file on the fly.
I’ve looked at a LOT of zip packages that would allow us to add directories and
Zip::Writer does that perfectly.
Anyways, we’ve got a working prototype that is mostly working. But when I try to zip a large number of files, sometimes the resulting zip is invalid (central directory is missing).
Given that I’m streaming this on-demand and simply storing the files (no compression), is there a way to check the integrity of the zip file? Or would that require creating the file locally on disk?
Also for reference, I’m starting the zip file like this:
env.response.output << Compress::Zip::Writer.open(env.response.output) do |zip|
I’m adding the contents of the file like this:
wasabi.get_object(bucket, wasabi_path) do |res| zip.add(file.as_h.dig("name").as_s, res.body_io) end
Lastly, is there anything about the way I’m adding contents of the zip file that could be a problem?