b0xxed1n
b0xxed1n

Reputation: 2343

How To Dynamically Route to Downloads

Basically, this is what my app does:

My question is, how do I dynamically route to the files I create so that they are accessible when you browse to them? If I don't add a route for them, then they will get a 404 if they try and access the directory they're in.

The files are currently stored in a folder in public.

Would the best way to deal with this make the folder somehow not require a route, so that it can be browsed to directly, and then have an index page on it so they can't view the full list of files? If so, please let me know how I can accomplish this. And on a side note, if you have an idea of how I can accomplish JS displaying the download dialog let me know.

It's Rails 3 by the way.

Thanks!

Upvotes: 1

Views: 77

Answers (1)

Pablo Castellazzi
Pablo Castellazzi

Reputation: 4184

For a full private set of files: choose a place for your files outside your public directory, then configure X-SendFile support in your web server and finally use send_file in your rails application.

Upvotes: 2

Related Questions