Sam 山
Sam 山

Reputation: 42865

Prevent File Download, RoR

I'm using Ruby on rails and I have videos that I don't want users to download.

Where do I store the videos? From the name of the folder "Public" maybe this is a really stupid question, but is that an ok ok place to store the videos?

Upvotes: 3

Views: 1095

Answers (3)

tanu jain
tanu jain

Reputation: 33

Just remove the right-click "save" option from the html5 videos

$(document).ready(function(){
  $('video').bind('contextmenu',function() { return false; });
});

Upvotes: 2

Andrew Nesbitt
Andrew Nesbitt

Reputation: 6046

Store your files somewhere other than the public directory when you upload them, in say for instance, downloads and then you can send files to a user with a controller action like:

def download
  send_file '/home/apps/myapp/downloads/video.mp4' 
end

That way you can authenticate the user with before filters and the file won't be available publicly.

Further reading: http://www.therailsway.com/2009/2/22/file-downloads-done-right

Upvotes: 2

titaniumdecoy
titaniumdecoy

Reputation: 19251

Users can download anything they can see. If you don't want anyone to access those videos, don't put them on the web.

Perhaps I don't understand your question; if so, please clarify.

Upvotes: 2

Related Questions