class Mongo::Grid::File

Will be removed in driver version 3.0.
@deprecated Please use the ‘stream’ API on a FSBucket instead.
@since 2.0.0
A representation of a file in the database.

def ==(other)

Other tags:
    Since: - 2.0.0

Returns:
  • (true, false) - If the objects are equal.

Parameters:
  • other (Object) -- The object to check against.

Other tags:
    Example: Check the equality of files. -
def ==(other)
  return false unless other.is_a?(File)
  chunks == other.chunks && info == other.info
end

def data

Other tags:
    Since: - 2.0.0

Returns:
  • (String) - The raw data for the file.
def data
  @data ||= Chunk.assemble(chunks)
end

def initialize(data, options = {})

Other tags:
    Since: - 2.0.0

Options Hash: (**opts)
  • :aliases (Array) -- A list of aliases.
  • :chunk_size (Integer) -- Override the default chunk
  • :metadata (String) -- Optional file metadata.
  • :content_type (String) -- The content type of the file.
  • :filename (String) -- Required name of the file.

Parameters:
  • options (BSON::Document, Hash) -- The info options.
  • data (IO, String, Array) -- The file object, file

Other tags:
    Example: Create the file. -
def initialize(data, options = {})
  options = options.merge(:length => data.size) unless options[:length]
  @info = Info.new(options)
  initialize_chunks!(data)
end

def initialize_chunks!(value)

Other tags:
    Note: - If we have provided an array of BSON::Documents to initialize
def initialize_chunks!(value)
  if value.is_a?(Array)
    @chunks = value.map{ |doc| Chunk.new(doc) }
  else
    @chunks = Chunk.split(value, info)
  end
end

def inspect

Other tags:
    Since: - 2.0.0

Returns:
  • (String) - The file inspection.

Other tags:
    Example: Get the file inspection. -
def inspect
  "#<Mongo::Grid::File:0x#{object_id} filename=#{filename}>"
end