Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails 3.0 beta1 send_file with 0 byte

#4063

when i am sending any file file is sent to client but size of file size is 0 byte.

Reported by Amar Daxini · February 26th, 2010 @ 07:56 AM

State: invalid
Milestone: none
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: Low

Activity

  1. fkocherga
    fkocherga

    It appears that Rails begins to rely on 'X-Sendfile' support by the server, you may try to use such kind of server or modify your config.ru file: http://gist.github.com/317072

    February 28th, 2010 @ 12:29 AM

  2. José Valim
    José Valim
    • State changed from new to invalid

    fkocherga is right. Please check for X-Sendfile support.

    March 3rd, 2010 @ 08:55 AM

  3. Robert Glaser
    Robert Glaser

    If you uncomment the line

    config.action_dispatch.x_sendfile_header = "X-Sendfile"
    

    in production.rb, send_file will deliver the file normally without passing it to the webserver.

    June 25th, 2010 @ 12:47 PM

  4. mafolz
    mafolz
    • Importance changed from to Low

    could it be that the following line 76 from actionpack/lib/action_controller/metal/streaming.rb make the problem?

     self.response_body = File.open(path, "rb")
    

    the response_body should include the binary data or? so they should be a .read behind the File.open

     self.response_body = File.open(path, "rb").read
    

    With this fix, send_file works for me with rails3.beta4 and the passenger version 2.2.15.
    could the zero byte file be a result from serialising the filehandler?

    August 2nd, 2010 @ 12:35 PM

  5. mail2fish
    mail2fish

    I have met this problem with rails 3 git and passenger 2.2.15.

    Then I comment config.action_dispatch.x_sendfile_header = "X-Sendfile" in production.rb

    The send_file is fine.

    August 13th, 2010 @ 05:10 AM

  6. Johan
    Johan

    I had the same problem on rails 3

    Thanks to mail2fish, comment config.action_dispatch.x_sendfile_header = "X-Sendfile" in production.rb and now all works fine...

    January 19th, 2011 @ 03:06 PM