Im looking for a way to download a xml file. I use:
file_path = 'folder/' + xml_name + '.xml'
send_file file_path, :type => "text/xml"
but this always downloads me an empty file. The file itself has 16 KB of data in it...
why is that?
Maechi
Im looking for a way to download a xml file. I use:
file_path = 'folder/' + xml_name + '.xml'
send_file file_path, :type => "text/xml"
but this always downloads me an empty file. The file itself has 16 KB of data in it...
why is that?
Maechi
probably you have to comment out
config.action_dispatch.x_sendfile_header = "X-Sendfile"
in production.rb
see http://vijaydev.wordpress.com/2010/12/15/rails-3-and-apache-x-sendfile/ for explanations
In my case same thing happened.
I was sending file and deleting it.
as here
File.open(file_path, 'r') do |f|
send_data f.read, filename: 'my_file.docx' , type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', disposition: 'attachment'
end
File.delete(file)
but
filename: 'my_file.docx'
save my day