# Sending a file to a user

**URL:** <https://www.ruby-forum.com/t/sending-a-file-to-a-user/148326>\
**Category:** Rails\
**Created:** [September 11, 2008, 7:11pm UTC](https://www.ruby-forum.com/t/sending-a-file-to-a-user/148326 "2008-09-11T19:11:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 11, 2008, 7:11pm UTC](https://www.ruby-forum.com/t/sending-a-file-to-a-user/148326/1 "2008-09-11T19:11:01Z")

</div>

Hello,

In my application I would like the user to download a file that is  
dynamically created from the database. Currently, I have rails put all  
the text into one variable and then save that to a temporary file with a  
filename that is generated from a sha1.

If a user requests a file, is there a way to automatically delete that  
temporary file when it is done downloading or should I just set up a  
cron job?

Or, if you have any other suggestion on how to send a file to a user  
there would be greatly appreciated.

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [September 12, 2008, 4:01am UTC](https://www.ruby-forum.com/t/sending-a-file-to-a-user/148326/2 "2008-09-12T04:01:20Z")

</div>

No need to save your data in a file. Just use send\_data [1].

Christian

[1]

> **[ActionController::Streaming](https://api.rubyonrails.org/classes/ActionController/Streaming.html#M000624)**
>
> 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 Thu, Sep 11, 2008 at 7:11 PM, Michael Lavrisha
