send_file example code -- permissions?

Hi, I'm having trouble getting send_file to work. I'm building a relatively small csv file, and trying to let the user download it.

My action to do the download looks like this:

  def send_the_file     @temp_download_file_path = session[:temp_file_path]     send_file @temp_download_file_path,                      :x_sendfile => true,                      :type => 'text/csv',                      :filename => "contacts.csv"   end

No errors are generated. Log says it is sending it. I wind up with an empty ( 1 byte) file on the other end. I get the same results with and without the "x_sendfile".

Any advice on where the file should reside on my server and how to set the necessary permissions to allow send_file to get at it? What else could I be doing wrong?

Thanks for any additional help you guys can provide.

jp

Shameless bump. I still really could use some help on this guys! There must be somebody out there who has used this.

thanks much, jp

Shameless bump. I still really could use some help on this guys! There must be somebody out there who has used this.

What's in the one byte?

send_file reads the file (in ruby) and spits the bytes out - the file doesn't have to be anywhere in particular, but it does need to be readable by your rails process. Have you tried sticking a breakpoint in there and see if you can open/read the file ? (I'd forget about x_sendfile for now)

Fred

Here’s some example code that covers nginx, apache, or plain old send_file:

http://github.com/kete/kete/tree/master/app/controllers/private_files_controller.rb

Works with 2.1, haven’t tried it with 2.2 RC1 yet.

Hope it helps.

Cheers,

Walter

Glad I could help. James Stradling was the guy that actually wrote
that particular bit of code.