# Creating a tar file for download

**URL:** <https://www.ruby-forum.com/t/creating-a-tar-file-for-download/161810>\
**Category:** Rails\
**Created:** [March 2, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/creating-a-tar-file-for-download/161810 "2009-03-02T17:26:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [March 2, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/creating-a-tar-file-for-download/161810/1 "2009-03-02T17:26:20Z")

</div>

Hello,

I have an action on my controller named download which creates a tar  
file and then sends the file (via send\_file) to the user. Its working  
but I will like to delete the file once it is sent. The tar file  
should be temporary and only available for download and then deleted  
from the server. Any idea on how to do this?  
Thanks,

def download  
@app = App.find params[:id]  
system('cd ‘+$removed\_email\_address@domain.invalid+’ && tar -cf ‘removed\_email\_address@domain.invalid+’.tar  
')  
send\_file $global\_path+"#{@app.name}/#{@app.name}.tar"  
end

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [March 2, 2009, 10:11pm UTC](https://www.ruby-forum.com/t/creating-a-tar-file-for-download/161810/2 "2009-03-02T22:11:10Z")

</div>

Basically I just want to be able to delete the file one it is  
download. Any ideas?
