Creating a zip file in memory not on disc

hi how i can create zip file in memory?
below is my code.
require ‘csv’
require ‘pry’
require ‘stringio’
require ‘tempfile’
require ‘rubygems’
require ‘zip’
#reading local csv file
table = CSV.parse(“sunil_test.csv”), headers: true)

#creating csv file in memory
temp_file = CSV.generate do |csv|
csv << table
stringio = Zip::OutputStream.write_buffer do |zio|
zio.write temp_file
stringio.rewind #reposition buffer pointer to the beginning
#below line is creating zip file on disc“”,“wb”).write(stringio.sysread) #write buffer to zipfile

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs