# Current best approach for Sending Files (streaming files e.g. images) in rails?

**URL:** <https://www.ruby-forum.com/t/current-best-approach-for-sending-files-streaming-files-e-g-images-in-rails/175824>\
**Category:** Rails\
**Created:** [September 20, 2009, 11:17pm UTC](https://www.ruby-forum.com/t/current-best-approach-for-sending-files-streaming-files-e-g-images-in-rails/175824 "2009-09-20T23:17:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 20, 2009, 11:17pm UTC](https://www.ruby-forum.com/t/current-best-approach-for-sending-files-streaming-files-e-g-images-in-rails/175824/1 "2009-09-20T23:17:46Z")

</div>

Hi,

Q1 - What’s the current most popular approach (plugin/gem or  
otherwise) for sending files / streaming files (e.g. images) back to a  
browser?

Q2 - Noting I’m on [Dreamhost.com](http://Dreamhost.com) on a shared environment (so don’t get  
much access to Apache), I was going to stick the images in mysql.  
Should keep things simple. Later if the service really gets used or  
response times are an issue I could change this approach (store them  
in a directory I create in the Rails app, but not under /public I  
guess). This should be OK no? Again I’m not sure how much access to  
Apache with [Dreamhost.com](http://Dreamhost.com) shared platform I would have and whether  
there would be a well known more performant option here.  
[http://wiki.dreamhost.com/Apache](http://wiki.dreamhost.com/Apache)

Background - So the main page would be referencing these images via a  
Rails controller to ensure authentication occurs. So it’s the  
standard scenario of allowing a user to upload files/images, but when  
they download them how to serve this back to them in an efficient  
fashion.

Tks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 21, 2009, 9:43am UTC](https://www.ruby-forum.com/t/current-best-approach-for-sending-files-streaming-files-e-g-images-in-rails/175824/2 "2009-09-21T09:43:32Z")

</div>

Greg -

Check out

> **[ActionController::Streaming](https://api.rubyonrails.org/classes/ActionController/Streaming.html)**
>
> Allows views to be streamed back to the client as they are rendered. By default, Rails renders views by first rendering the template and then the layout.

On Sep 20, 10:07 pm, Greg H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [September 21, 2009, 2:43pm UTC](https://www.ruby-forum.com/t/current-best-approach-for-sending-files-streaming-files-e-g-images-in-rails/175824/3 "2009-09-21T14:43:39Z")

</div>

Greg H. wrote:

> Hi,
> 
> Q1 - What’s the current most popular approach (plugin/gem or  
> otherwise) for sending files / streaming files (e.g. images) back to a  
> browser?

Put them in the public directory. That way Rails’ involvement is  
minimized.

> Q2 - Noting I’m on [Dreamhost.com](http://Dreamhost.com) on a shared environment (so don’t get  
> much access to Apache), I was going to stick the images in mysql.  
> Should keep things simple.

No, actually it will complicate things, or so say people who’ve done it  
this way. Images belong in the filesystem, not the DB.

[…]

> Background - So the main page would be referencing these images via a  
> Rails controller to ensure authentication occurs. So it’s the  
> standard scenario of allowing a user to upload files/images, but when  
> they download them how to serve this back to them in an efficient  
> fashion.

Have you bothered to read the recent discussions on this list? There’s  
always a lot of talk of using Paperclip and send\_file for exactly this.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

> Tks
