class MongoGridFSFile (View source)

Properties

array|null $file
protected MongoGridFS|null $gridfs

Methods

__construct(MongoGridFS $gridfs, array $file)

No description

string
getFilename()

Returns this file's filename

int
getSize()

Returns this file's size

int
write(string $filename = null)

Writes this file to the filesystem

string
getBytes()

This will load the file into memory. If the file is bigger than your memory, this will cause problems!

resource
getResource()

This method returns a stream resource that can be used to read the stored file with all file functions in PHP.

Details

__construct(MongoGridFS $gridfs, array $file)

No description

Parameters

MongoGridFS $gridfs

The parent MongoGridFS instance

array $file

A file from the database

string getFilename()

Returns this file's filename

Return Value

string

Returns the filename

int getSize()

Returns this file's size

Return Value

int

Returns this file's size

int write(string $filename = null)

Writes this file to the filesystem

Parameters

string $filename

The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used.

Return Value

int

Returns the number of bytes written

string getBytes()

This will load the file into memory. If the file is bigger than your memory, this will cause problems!

Return Value

string

Returns a string of the bytes in the file

resource getResource()

This method returns a stream resource that can be used to read the stored file with all file functions in PHP.

The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first. At most two GridFSFile chunks will be loaded in memory.

Return Value

resource

Returns a resource that can be used to read the file with