# Serve files by alias

**URL:** <https://www.ruby-forum.com/t/serve-files-by-alias/157299>\
**Category:** Mongrel\
**Created:** [January 9, 2009, 8:36am UTC](https://www.ruby-forum.com/t/serve-files-by-alias/157299 "2009-01-09T08:36:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c2a13f/32.png) [@dust](https://www.ruby-forum.com/u/dust)\
**Post date:** [January 9, 2009, 8:36am UTC](https://www.ruby-forum.com/t/serve-files-by-alias/157299/1 "2009-01-09T08:36:33Z")

</div>

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](http://example.com/file/1337) serves /u01/media/some.ogm  
[http://example.com/file/2342](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  
platform.

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  
topic.

Thanks in advance!

Erik.

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  
reasons.  
It took my ages to send this post to your site, chaining tor with  
other proxy.
