开发者

Respond with video file from local disk

I'm trying to create controllers action that responds with local vide开发者_Python百科o file that is outside of the applications public directory. What I have now is

def video
  render :text => File.read('D:/test.mp4'), :content_type => 'video/mp4'
end

browser recognizes that it should threat response as a video file however video content is not played appropriately. Am I missing something here? Do you know some better/other solution? Copying each file to the public directory seems to be a workaround but it also seems to be a really bad idea ). Thanks.


You should use send_file or send_data instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜