# File multipart.rb, line 143
      def set_multipart_data(files_params,
                             other_params={},
                             boundary1="paranguaricutirimirruaru0xdeadbeef",
                             boundary2="paranguaricutirimirruaru0x20132")

        self.content_type = "multipart/form-data; boundary=\"#{boundary1}\""

        tmp = StringIO.new('r+b')

        # let's do the easy ones first
        other_params.each do |key,val|
          tmp.write "--#{boundary1}\r\n"
          tmp.write "content-disposition: form-data; name=\"#{key}\"\r\n"
          tmp.write "\r\n"
          tmp.write "#{val}\r\n"
        end

        # now handle the files...
        files_params.each do |name, file|
          tmp.write "\r\n--#{boundary1}\r\n"

          # no \r\n
          tmp.write "content-disposition: form-data; name=\"#{name}\""

          if not file.is_a? Enumerable
            # single-file multipart is different

            if file.filename
              # right in content-dispo line
              tmp.write "; filename=\"#{file.filename}\"\r\n"
            else
              tmp.write "\r\n"
            end

            tmp.write "Content-Type: #{file.mimetype}\r\n"
            tmp.write "Content-Transfer-Encoding: binary\r\n"
            tmp.write "\r\n"
            tmp.write(file.read())
            file.maybeclose
          else
            # multiple-file parameter (multipart/mixed)
            tmp.write "\r\n"
            tmp.write "Content-Type: multipart/mixed;"
            tmp.write " boundary=\"#{boundary2}\"\r\n"

            file.each do |f|
              tmp.write "\r\n--#{boundary2}\r\n"

              tmp.write "Content-disposition: attachment"
              if f.filename
                tmp.write "; filename=\"#{f.filename}\"\r\n"
              else
                tmp.write "\r\n"
              end

              tmp.write "Content-Type: #{f.mimetype}\r\n"
              tmp.write "Content-Transfer-Encoding: binary\r\n"
              tmp.write "\r\n"
              tmp.write(f.read())
              f.maybeclose
            end
            tmp.write "\r\n--#{boundary2}--\r\n"
          end
        end
        tmp.write "--#{boundary1}--\r\n"

        
        tmp.flush
        self.content_length = tmp.size
        self.body_stream = tmp
        self.body_stream.seek(0)
        nil
      end