Rails + X-Sendfile serving large video to Ipad -


i have application serving large (some hundreds of mb) video files , working on desktop browsers, using rails + x-sendfile on apache. important requirement these videos must private , visible logged users, that's why i'm using rails serve them.

everything works other devices. serve videos in way:

response.headers["x-sendfile"]=  filename send_file filename, :disposition => :inline, :stream => true, :x_sendfile => true 

but ipad's requests need byte range header. solution (that not work perfectly) this:

size = file.size(filename) bytes = rack::utils.byte_ranges(request.headers, size)[0] offset = bytes.begin length = bytes.end  - bytes.begin  response.header["accept-ranges"]=  "bytes" response.header["content-range"] = "bytes #{bytes.begin}-#{bytes.end}/#{size}"  send_data io.binread(filename,length, offset), :type => "video/mp4", :stream => true, :disposition => 'inline', :file_name => filename  

with solution have problems larger 50mb videos, and, more important, i'm giving rails responsibility shouldn't have. should apache handle heavy load of streaming, through x-sendfile module. dont know how. send_data method not have x-sendfile parameter, , solutions involving send_file method not working.

i found these 2 questions similar mine not working: rails media file stream accept byte range request through send_data or send_file method, what proper way serve mp4 files through rails ipad?

any clue on what's going on? i'm struggling since weeks , need make work. other feasible solutions welcome.

this unrelated using nginx server, if not working ios, take @ this blog post. there similar solution apache.

in sense, had add proxy header internally redirects folder path. how ever stupid may seem, apple has sort of privacy issues make necessary playback audio , video files. again not sure if solution nginx did wonders , cured month long headache.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -