Method: Mongo::Grid::FSBucket#download_to_stream

Defined in:
lib/mongo/grid/fs_bucket.rb

#download_to_stream(id, io) ⇒ Object

Downloads the contents of the file specified by id and writes them to the destination io object.

Examples:

Download the file and write it to the io object.

fs.download_to_stream(id, io)

Parameters:

  • id (BSON::ObjectId, Object)

    The id of the file to read.

  • io (IO)

    The io object to write to.

Since:

  • 2.1.0



271
272
273
274
275
276
277
# File 'lib/mongo/grid/fs_bucket.rb', line 271

def download_to_stream(id, io)
  open_download_stream(id) do |stream|
    stream.each do |chunk|
      io << chunk
    end
  end
end