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

2011/5/27 Sayuj O. [email protected]

http://groups.google.com/group/rubyonrails-talk?hl=en.


Mediouni Adel
Tunis
www.metal-tn.xooit.com

On Fri, May 27, 2011 at 10:00 AM, Sayuj O.
[email protected]wrote:

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.

On Fri, May 27, 2011 at 10:00 PM, Sayuj O.
[email protected]wrote:

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

[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

On Fri, May 27, 2011 at 10:00 AM, Sayuj O.
[email protected]wrote:

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”)

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.

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