I use send_data to send zip file from ruby to node.js server. my ruby code is:
temp_file = Tempfile.new("file.csv")
CSV.open(temp_file, "w") do |csv|
csv << [1,2,3]
end
zip = Tempfile.new("basic.zip")
Zip::ZipOutputStream.open(zip) do |zos|
zos.put_next_entry("basic_usages.csv")
zos.print IO.read(temp_file.path)
end
zip_data = File.read(zip.path)
send_data(Base64.encode64(zip_data), :filename => 'data.zip', :type => 'application/zip')
in the node js I get the data something like:
UEsDBBQAAAAIAPxgIUU+wIQWiQAAALMBAAAQAAAAYmFzaWNfdXNhZ2VzLmNz
dgsuyS9K9XTRCakAE/E5+cmJJZn5eTpBIIHgksSikviSzNxUHde8FDCDK8DX
T9c1JzHFUMfNwNTF2cLA0M3I1U0HxjOxdLV01DEw1Te01DcyMDRRMDC3MjG0
MjDAJkbYMEdHSwoMM3R1NCDHZYbYDXO2xG+YEaZhpuZWxkakG2ZhZWCGbhhU
jAsAUEsBAjQDFAAAAAgA/GAhRT7AhBaJAAAAswEAABAAAAAAAAAAAQAAAKSB
AAAAAGJhc2ljX3VzYWdlcy5jc3ZQSwUGAAAAAAEAAQA+AAAAtwAAAAAA
what should I do for extract and read the file in node.js
I looked for this for a long time, and try few options with no success.
Can you please help me?
Thanks in advance