I think I just found the answer to my question.
This is Zip :: ZipOutputStream.write_buffer . I will check this and update this answer when I earn it.
Update
He works. My code is as follows:
compressed_filestream = Zip::ZipOutputStream.write_buffer do |zos| some_file_list.each do |file| zos.put_next_entry(file.some_title) zos.print IO.read(file.path) end end
write_buffer returns StringIO and should rewind the stream first read . Now I do not need to create and delete the tmp file.
I am just wondering now if write_buffer will have more memory large or heavy than open ? Or is it the other way around?
index source share