[Mongrel] failed to allocate memory while downloading large files

Amit Tomar lists at ruby-forum.com
Tue Sep 14 11:11:08 EDT 2010

Luis Lavena wrote:
> On Tue, Sep 14, 2010 at 11:14 AM, Amit Tomar <lists at ruby-forum.com> 
> wrote:
>> luis ,but do n't have option other than send_data and one thing i can do
>> is while downloading large files i can do it in chunks but i only
>> download 4096 byte ,this is my code
> please read about streaming data without loading all the file contents.
> You will need to either use rack directly or create a mongrel handler
> to serve these files outside rails.
> Rails can only deliver one full request meaning it will load the full
> file before completing.
> --
> Luis Lavena
> AREA 17
> -
> Perfection in design is achieved not when there is nothing more to add,
> but rather when there is nothing more to take away.
> Antoine de Saint-Exup鲹

      File.open(@containerformat.location,"rb") do |f|
      while @buffer = f.read(4096)

      ext = File.extname(@containerformat.streamName)

      if ext == ''
        extension = File.extname(@containerformat.location)

        #send_to_web_app(pos, buffer)

        send_data(@buffer,:filename => @containerformat.name+extension,
        :disposition => 'attachment')


      send_data(@buffer,:filename => @containerformat.streamName,
        :disposition => 'attachment')

now am doing it like above and trying to download 284mb of file
but only 211 bytes of file being downloaded..

Posted via http://www.ruby-forum.com/.

More information about the Mongrel-users mailing list