Finally found out how to achieve this!
Turned out it is as simple as enabling xsendfile and setting header parameter Accept-Range
Read my answer below
(by the way, in the block quote below I wrote a common pitfall newbies - like I did - made. We tend to think it should be manually programmed)
URL must be something like: mysite.com/get_file?file_point=100 -> this will read from byte 100
- Get the offset from parameter (file_point parameter in our example)
- Find out size of file (File.size)
- Read the file from offset to length (Equivalent of fseek in PHP)
- Send the file using send_file
I dont know how to do step #3 in Ruby in the steps above.
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