I would like to put some html5 videos inside my page, but the access to this video can be given only to logged in users (so non-logged in users must not see the video, also if they have the url):
<video width="320" height="240" controls>
<source src="/video.mp4" type="video/mp4">
<source src="/video.m4v" type="video/m4v">
Your browser does not support the video tag.
</video>
I tried with something like this in my action (with a before filter for access restriction):
def video
respond_to do |format|
format.m4v{
send_data File.join([Rails.root, "public", "videos", "sample.m4v"]), type: 'video/m4v', disposition: :inline
}
format.mp4{
send_data File.join([Rails.root, "public", "videos", "sample.mp4"]), type: 'video/mp4', disposition: :inline
}
end
end
but this is sending the file as an attachment, and not just serving it.
Is it possible? and, if yes, how can it be done?
thank you