Forum: Ruby on Rails download manager?? anyone?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jon M. (Guest)
on 2006-05-23 01:40
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
Frodo L. (Guest)
on 2006-05-23 02:12
(Received via mailing list)
On 5/22/06, Jon Mr <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.
Frodo L. (Guest)
on 2006-05-23 02:21
(Received via mailing list)
instead of hand coding it, you can also use send_data or send_file:

http://api.rubyonrails.org/classes/ActionControlle...
--
Sincerely,

Frodo L.
Ezra Z. (Guest)
on 2006-05-23 03:23
(Received via mailing list)
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/

Cheers-
-Ezra
Michael T. (Guest)
on 2006-05-23 03:57
(Received via mailing list)
wow, that's sweet.  Thanks for the tip Ezra.

Michael
Jon M. (Guest)
on 2006-05-23 18:09
Hey thanks guys! (and gals).  That's why i love this stuff, it's the
community.

Jon
This topic is locked and can not be replied to.