I am creating a zip file using the technique described here:
http://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/
The client has asked that I include subdirectories in this zip file. I have searched the ZipOutputStream documentation but I see no way to include directories. Is there a way I can do this with ZipOutputStream? Should I be using a different class than ZipOutputStream?
Also, the files that I am zipping are not on the local filesystem, but are stored in a cloud service.
Figured out the answer, thought I would put it here for search engines to find.
Anyway, the link I posted used
zos.put_next_entry("some-funny-name.jpg")
to add files to the zip file. Turns out, that string parameter isn't just a filename, it can be a path as well! So using
zos.put_next_entry("some-random-folder/some-funny-name.jpg")
Will make your zip file contain a folder called 'some-random-folder', with a file called 'some-funny-name.jpg'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With