开发者

Respond with video file from local disk

开发者 https://www.devze.com 2023-04-08 18:25 出处:网络
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

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

精彩评论

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