# Best way to serve/upload documents

**URL:** <https://www.ruby-forum.com/t/best-way-to-serve-upload-documents/133395>\
**Category:** Rails\
**Created:** [March 31, 2008, 8:08am UTC](https://www.ruby-forum.com/t/best-way-to-serve-upload-documents/133395 "2008-03-31T08:08:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miken700](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@miken700](https://www.ruby-forum.com/u/miken700)\
**Post date:** [March 31, 2008, 8:08am UTC](https://www.ruby-forum.com/t/best-way-to-serve-upload-documents/133395/1 "2008-03-31T08:08:35Z")

</div>

I have two projects where the entire site’s contents are only available  
to logged in users. These users can share documents and files.

Is there a best practice for handling a situation like this?

Is there a way I can make Apache serve the files, instead of Mongrel,  
but also make sure the files are only available to certain users?

Naturally, any links to relevant articles would be much appreciated.

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![miken700](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@miken700](https://www.ruby-forum.com/u/miken700)\
**Post date:** [March 31, 2008, 8:15am UTC](https://www.ruby-forum.com/t/best-way-to-serve-upload-documents/133395/2 "2008-03-31T08:15:15Z")

</div>

Maybe you should use HTTP realms based authentication.

This will solve both of your issues, I believe.

Google is your friend.

Julian.

---

<div class="post-metadata">

**Author:** ![miken700](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@miken700](https://www.ruby-forum.com/u/miken700)\
**Post date:** [March 31, 2008, 10:14am UTC](https://www.ruby-forum.com/t/best-way-to-serve-upload-documents/133395/3 "2008-03-31T10:14:06Z")

</div>

On 31 Mar 2008, at 08:08, Mike Nicholaides wrote:

> I have two projects where the entire site’s contents are only  
> available  
> to logged in users. These users can share documents and files.
> 
> Is there a best practice for handling a situation like this?
> 
> Is there a way I can make Apache serve the files, instead of Mongrel,  
> but also make sure the files are only available to certain users?

You need to add the xsendfile module to Apache and then use some  
header magic to send out the file.

> Naturally, any links to relevant articles would be much appreciated.

[http://john.guen.in/past/2007/4/17/send\_files\_faster\_with\_xsendfile/](http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/)

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![miken700](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@miken700](https://www.ruby-forum.com/u/miken700)\
**Post date:** [March 31, 2008, 5:04pm UTC](https://www.ruby-forum.com/t/best-way-to-serve-upload-documents/133395/4 "2008-03-31T17:04:44Z")

</div>

Thanks! That’s exactly what I was looking for. I had seen that before,  
but I had no idea how to find it again.
