struct Mongo::GridFS::File(FileID)

Overview

A GridFS file document.

Included Modules

Defined in:

cryomongo/gridfs.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(bson : BSON) #

Allocate an instance and copies data from a BSON struct.

class User
  include BSON::Serializable
  property name : String
end

data = BSON.new
data["name"] = "John"
User.new(data)

Class Method Detail

def self.from_bson(bson : BSON) #

NOTE See self.new.


Instance Method Detail

def _id : FileID #

A unique ID for this document. Usually this will be of type ObjectId, but a custom _id value provided by the application may be of any type.


def _id=(_id : FileID) #

A unique ID for this document. Usually this will be of type ObjectId, but a custom _id value provided by the application may be of any type.


def chunk_size : Int64 #

The size, in bytes, of each data chunk of this file. This value is configurable by file. The default is 255 KiB.


def chunk_size=(chunk_size : Int64) #

The size, in bytes, of each data chunk of this file. This value is configurable by file. The default is 255 KiB.


def filename : String #

The name of this stored file; this does not need to be unique.


def filename=(filename : String) #

The name of this stored file; this does not need to be unique.


def length : Int64 #

The length of this stored file, in bytes.


def length=(length : Int64) #

The length of this stored file, in bytes.


def metadata : BSON? #

Any additional application data the user wishes to store.


def metadata=(metadata : BSON?) #

Any additional application data the user wishes to store.


def to_bson(bson = BSON.new) #

Converts to a BSON representation.

user = User.new name: "John"
bson = user.to_bson

def upload_date : Time #

The date and time this file was added to GridFS, stored as a BSON datetime value.


def upload_date=(upload_date : Time) #

The date and time this file was added to GridFS, stored as a BSON datetime value.