On 10/10/06, Nick <nicksmooth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> When I try to download a very large file (700MB) using send_file I get
> a NoMemoryError (failed to allocate memory) error. It does look like I
> am really running out of memory, because I am watching the memory grow
> when this piece of code excutes. What typically happens on the client
> side is that it sends only 256MB of the file to be downloaded. I am
> stumped and not sure if this is a Windows, Mongrel, Rails, or ruby
> issue. I thought send_file was supposed to stream a file in small
> packets so file size wasn''t an issue, but this doesn''t
seem to be the
> case.
>
> My set up is a Rails App. running on Windows Server 2003, Apache 2.2.3
> w/ two Mongrel 0.3.13.3 services running.
>
> Here is the controller code that is erring:
>
> @document = Document.find(params[:id])
> send_file(FILE_UPLOAD_ROOT + @document.url.strip)
>
> Additionally, I have tried this:
>
> @document = Document.find(params[:id])
> fn = FILE_UPLOAD_ROOT + @document.url.strip
> file_name = File.basename(fn.gsub(''\\'',
''/'')).gsub(/[^\w\.\-]/,''_'')
> send_file(FILE_UPLOAD_ROOT + @document.url.strip, :streaming => true,
> :type => ''application/octet-stream'', :disposition
=> ''attachment'',
> :filename => file_name)
>
> Any help would be appreciated!
Mongrel buffers the Rails response to a StringIO then sends to the client
when the request is finished. I recommend using the X-Sendfile:
/path/to/file header with Apache2 mod_xsendfile instead of streaming from
Rails.
jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---