# Download manager? anyone?

**URL:** <https://www.ruby-forum.com/t/download-manager-anyone/61306>\
**Category:** Rails\
**Created:** [May 22, 2006, 11:40pm UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306 "2006-05-22T23:40:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jon-d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jon-d](https://www.ruby-forum.com/u/jon-d)\
**Post date:** [May 22, 2006, 11:40pm UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306/1 "2006-05-22T23:40:39Z")

</div>

Hello all,

i have been searching for some time now on how to upload files and then  
display them to be downloaded, haven’t had any luck. it seems all the  
documentation is for uploading and displaying pictures. is this the same  
thing? i’m lost… any help would be greatly appreciated.

Jon

---

<div class="post-metadata">

**Author:** ![jon-d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jon-d](https://www.ruby-forum.com/u/jon-d)\
**Post date:** [May 23, 2006, 12:12am UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306/2 "2006-05-23T00:12:25Z")

</div>

On 5/22/06, Jon Mr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello all,
> 
> i have been searching for some time now on how to upload files and then  
> display them to be downloaded, haven’t had any luck. it seems all the  
> documentation is for uploading and displaying pictures. is this the same  
> thing? i’m lost… any help would be greatly appreciated.

Hi Jon,

Assuming you already uploaded the data to your database, you can do  
something like this to show it:

# Show a binary file

def download\_file  
@filedata = FileData.find(@params[:id])

```
  @response.headers['Pragma'] = ' '
  @response.headers['Cache-Control'] = ' '
  @response.headers['Content-type'] = @filedata.mime_type
  @response.headers['Accept-Ranges'] = 'bytes'
  @response.headers['Content-Length'] = @filedata.data.length
  @response.headers['Content-Transfer-Encoding'] = 'binary'
  @response.headers['Content-Description'] = 'File Transfer'
  # Remove the following comment if you want to force downloading

```

instead of viewing inline

# @response.headers[‘Content-Disposition’] = "attachment;

filename=#{@filedata.filename}"  
render\_text @filedata.data  
end

–  
Sincerely,

Frodo L.

---

<div class="post-metadata">

**Author:** ![jon-d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jon-d](https://www.ruby-forum.com/u/jon-d)\
**Post date:** [May 23, 2006, 12:21am UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306/3 "2006-05-23T00:21:48Z")

</div>

instead of hand coding it, you can also use send\_data or send\_file:

## [ActionController::Streaming](http://api.rubyonrails.org/classes/ActionController/Streaming.html#M000073)

Sincerely,

Frodo L.

---

<div class="post-metadata">

**Author:** ![jon-d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jon-d](https://www.ruby-forum.com/u/jon-d)\
**Post date:** [May 23, 2006, 1:57am UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306/4 "2006-05-23T01:57:35Z")

</div>

wow, that’s sweet. Thanks for the tip Ezra.

Michael

---

<div class="post-metadata">

**Author:** ![jon-d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jon-d](https://www.ruby-forum.com/u/jon-d)\
**Post date:** [May 23, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306/5 "2006-05-23T16:09:33Z")

</div>

Hey thanks guys! (and gals). That’s why i love this stuff, it’s the  
community.

Jon

---

<div class="post-metadata">

**Author:** ![jon-d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jon-d](https://www.ruby-forum.com/u/jon-d)\
**Post date:** [May 23, 2006, 1:23am UTC](https://www.ruby-forum.com/t/download-manager-anyone/61306/6 "2006-05-23T01:23:28Z")

</div>

On May 22, 2006, at 2:40 PM, Jon Mr wrote:

> –

Jon-

```
Here is an open source rails app that is a file upload and download

```

manager. I think you could learn all you are looking for by browsing  
the source.

[http://boxroom.rubyforge.org/](http://boxroom.rubyforge.org/)

Cheers-  
-Ezra
