# File lib/mongo/gridfs/grid_io.rb, line 118
    def write(io)
      raise GridError, "file not opened for write" unless @mode[0] == ?w
      if io.is_a? String
        if Mongo::WriteConcern.gle?(@write_concern)
          @local_md5.update(io)
        end
        write_string(io)
      else
        length = 0
        if Mongo::WriteConcern.gle?(@write_concern)
          while(string = io.read(@chunk_size))
            @local_md5.update(string)
            length += write_string(string)
          end
        else
          while(string = io.read(@chunk_size))
            length += write_string(string)
          end
        end
        length
      end
    end