[Mongrel] Serve files by alias

Erik Berg lists at ruby-forum.com
Fri Jan 9 02:36:33 EST 2009

Hi there.

I'd like to serve a bunch of files stored in the filesystem. Unlike
serving them directly by their name, I would like to have them served
by ID, e.g. like

http://example.com/file/1337 serves /u01/media/some.ogm
http://example.com/file/2342 serves /u01/media/other.ogm

Further I need to add (and eventually modify) headers in the
response created by the webserver.

I choosed to do realize it with mongrel, because webrick is told
to be slow serving big files. I choosed not to use e.g. nginx
directly, because the application should be easily deployable on
different platforms where ruby is available, without compiling
needed and spending much time getting it work in some special

Now to my problem... :)

I wasn't able to figure out, how to "link" static files into the
webspace, like the Alias directive of apache e.g..

The idea was that mongrel should serve e.g. /u01/media/some.ogm
if /file/1337 is requested and the header modification would be
done by a handler hooked onto /file.

Is that possible, or have I read to and send the files on my own
by a servlet?

I'd be very happy for comments, tips or sample code regarding this

Thanks in advance!


PS: It's a pity that you blacklist posting from Tor nodes.
I understand that some people could abuse it for spamming, but
please also think about that not everybody has the luxury to use
the internet unanonymously without beeing afraid, for whatever
It took my ages to send this post to your site, chaining tor with
other proxy.
Posted via http://www.ruby-forum.com/.

More information about the Mongrel-users mailing list