lib/mongo/grid/stream/write.rb in mongo-2.11.6 vs lib/mongo/grid/stream/write.rb in mongo-2.12.0.rc0

- old
+ new

@@ -80,29 +80,23 @@ @options.freeze @filename = @options[:filename] @open = true end - # Write to the GridFS bucket from the source stream or a string. + # Write to the GridFS bucket from the source stream. # # @example Write to GridFS. # stream.write(io) # - # @param [ String | IO ] io The string or IO object to upload from. + # @param [ IO ] io The source io stream to upload from. # # @return [ Stream::Write ] self The write stream itself. # # @since 2.1.0 def write(io) ensure_open! @indexes ||= ensure_indexes! - @length += if io.respond_to?(:bytesize) - # String objects - io.bytesize - else - # IO objects - io.size - end + @length += io.size chunks = File::Chunk.split(io, file_info, @n) @n += chunks.size chunks_collection.insert_many(chunks) unless chunks.empty? self end