I have generated many PDF files in memory and I want to compress them into one zip file before sending it as a email attachment. I have looked at Rubyzip and it does not all
Ruby comes with a very convenient StringIO
library - this can be used for using a String as output IO object or faking reading a file backed by a String.
The challenge here is that RubyZip does not support directly taking an IO object when creating a Zip::ZipOutputStream
, but if you look at the implementation of the initialize
, and depending on your willingness to experiment, you may be able to extend the class and allow it to take either an IO object or a file name in the constructor.