views:

48

answers:

2

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?

+2  A: 

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.

titaniumdecoy
I believe the OP is indicating that the videos are needed in the app (perhaps for streaming? who knows) but that they don't need to be (and shouldn't be) externally available. Essentially, how to keep the files private to the web server.
Marc Gravell
Yeah. If you sell videos online that are viewed in the browser maybe you don't want your users to directly download these videos. So in RoR how can you do that?
Sam
If you're on linux, you can just go to tmp directory and copy anything that is being streamed onto your desktop. Same in windows. Sorry, I don't think it can be done.... But yeah, the public directory is a good enough place to store these files
stephenmurdoch
+1  A: 

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

Andrew Nesbitt