Ruby on Rails - send_file

I am using the send_file method to download a file. It works fine on my
local machine. But it's not working on the server - it returns a blank
file.

code:

send_file Rails.root.join('public', 'uploads') +
(uploaded_file.original_filename + ".filtered")

Please help.

try with send_data

I am using the send_file method to download a file. It works fine on my

local machine. But it’s not working on the server - it returns a blank

file.

code:

send_file Rails.root.join(‘public’, ‘uploads’) +

(uploaded_file.original_filename + “.filtered”)

try doing:

file = Rails.root.join(‘public’, ‘uploads’) +

(uploaded_file.original_filename + “.filtered”)

puts “@@@@@@@@@@@@@ #{file}”

send_file file

make sure file is valid.

I am using the send_file method to download a file. It works fine on my

local machine. But it’s not working on the server - it returns a blank

file.

code:

send_file Rails.root.join(‘public’, ‘uploads’) +

(uploaded_file.original_filename + “.filtered”)

if you’re using nginx or apache, you might want to look at

http://stackoverflow.com/questions/3724853/rails-sends-0-byte-files-using-send-file

by the way it makes no sense to use send file here, since the file is in the pubic folder it can be served by the web server, if you were trying to implement some sort of authorization is not working and the file and be downloaded without authorization (unless you assign them in the web server). Use send file when the files are out of the reach of the web server or when if you want to control access to the file move out of the public folder.