> How about
>
>   require 'fileutils'
>   File.open(upload, 'w') {|f| FileUtils.copy_stream(file,f)}
>
> ?  It's bit longer, but works now without any modifies.

I think this will best serve my needs within the current constraints of 
CGI.rb's multipart handling.

Coming from a PHP backgrund, I was initially thrown by the inability to 
access the actual file -- not really considering that I needed to turn 
the stream into a file myself. And since CGI.rb uses tempfile itself 
for larger file uploads, this made it even more confusing.

So yes, this is probably largely a documentation issue. It would be 
*great* with an example somewhere that used the solution by matz to 
demonstrate how to handle it.

That said, I strongly agree with Austin that this distinction is 
conceptually broken. I have other infrastructure code that relies on 
the regular CGI.rb interface for accessing form fields. It's a great 
pain to add kludges for accessing form fields that are part of a 
multipart request. It offloads what I perceive as plumbing details to 
the application. It just feels wrong and un-Ruby like.

Again, this could be my bias coming from PHP where multipart requests 
are exposed equal to normal requests. But it sounds like Austin 
expected the same thing coming from Perl.

Ruby is all about consistent behaviour and the principle of least 
surprise. This is inconsistent and highly surprising behaviour.
--
David Heinemeier Hansson.
http://www.loudthinking.com/ -- Broadcasting Brain