| Class | Mongo::Grid::FSBucket::Stream::Read |
| In: |
lib/mongo/grid/stream/read.rb
|
| Parent: | Object |
A stream that reads files from the FSBucket.
@since 2.1.0
Close the read stream.
@example Close the stream.
stream.close
@return [ BSON::ObjectId, Object ] The file id.
@raise [ Error::ClosedStream ] If the stream is already closed.
@since 2.1.0
Is the stream closed.
@example Is the stream closd.
stream.closed?
@return [ true, false ] Whether the stream is closed.
@since 2.1.0
Iterate through chunk data streamed from the FSBucket.
@example Iterate through the chunk data.
stream.each do |data|
buffer << data
end
@return [ Enumerator ] The enumerator.
@raise [ Error::MissingFileChunk ] If a chunk is found out of sequence.
@yieldparam [ Hash ] Each chunk of file data.
@since 2.1.0
Get the files collection file information document for the file being read.
@example Get the file info document.
stream.file_info
@return [ Hash ] The file info document.
@since 2.1.0
Read all file data.
@example Read the file data.
stream.read
@return [ String ] The file data.
@raise [ Error::MissingFileChunk ] If a chunk is found out of sequence.
@since 2.1.0
Get the read preference used when streaming.
@example Get the read preference.
stream.read_preference
@return [ Mongo::ServerSelector ] The read preference.
@since 2.1.0