Sorry if Ruby 1.6 is an ancient history for some, but I still see a
point in reporting bugs related to it.

It took me a while to figure out why file upload didn't want to work at
all in Samizdat. What I found was a misunderstanding between yaml.rb,
which defines a limited StringIO class without 'binmode' method, and
cgi.rb, which assumes that if there is StringIO class, it has a
'binmode' method.

As a result, I receive following error whenever I upload a file:

/usr/lib/ruby/1.6/cgi.rb:653:in `read_multipart': undefined method
`binmode' for
 #<StringIO:0x404a89e4> (NameError)
        from /usr/lib/ruby/1.6/cgi.rb:744:in `initialize_query'
        from /usr/lib/ruby/1.6/cgi.rb:1587:in `initialize'

Offending code in cgi.rb:

        if 10240 < content_length
          require "tempfile"
          body = Tempfile.new("CGI")
        else
          begin
            require "stringio" if not defined? StringIO
            body = StringIO.new
          rescue LoadError
            require "tempfile"
            body = Tempfile.new("CGI")
          end
        end
        body.binmode

A dirty workaround I had to use:

if defined? StringIO and
        not StringIO.instance_methods(true).include? 'binmode' then
    class StringIO
        def binmode
        end
    end
end

I think it is a bug both in yaml.rb, which should at least define (if
not implement, or inherit, or borrow somewhere) all methods found in
standard StringIO from Ruby 1.8, and in cgi.rb, which should check for
body.type.instance_methods(true).include? 'binmode'.

-- 
Dmitry Borodaenko