I have requirement to download generated XML files to local machine. I compress files into .zip file and then use send_data function to download it. I am getting status:
Sent data xml_idocs.zip (7.6ms) Completed 200 OK in 61ms (Views: 7.4ms | ActiveRecord: 4.6ms)
. The problem is that file is not downloading. I tried it on development and production environments using Opera and Chrome browsers. How can I fix it?
Code:
filename = 'xml_idocs.zip'
zip_filestream = Zip::OutputStream.write_buffer do |zos|
zos.put_next_entry 'MATMAS05.xml'
zos.print builder.to_xml
zos.put_next_entry 'MATQM01.xml'
zos.print builder1.to_xml
end
zip_filestream.rewind
send_data zip_filestream.read, :filename => filename, :type => 'application/zip', :disposition => 'attachment'