4

I am trying to make my Rails app support resuming of downloads, since we serve quite large files from there. I found a piece of middleware to do this long ago, but I cant find it again. Any tips/tricks on how to pull it off?

Thanks! :)

kmnd
  • 85
  • 1
  • 7

1 Answers1

6

This was how I did it:

response.header["Accept-Ranges"] = "bytes"
send_file product.pack.path, :type => product.pack_content_type, :x_sendfile=>true

I asked our server guy to set up mod_xsendfile, I don't know how to set it myself.

Tutorial here: http://www.devsource.com/c/a/Techniques/Resumable-File-Downloads-with-ASPNet/2/

Read about content-length here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

About streaming is available here: http://api.rubyonrails.org/classes/ActionController/Streaming.html

jaycode
  • 2,926
  • 5
  • 35
  • 71
  • Upvoting this, I ended up using the excellent Nginx X-Accel-Redirect. See here: http://kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/ – kmnd Jun 22 '11 at 02:12