PHP Class MongoGridFSFile

Author: Johannes Skov Frandsen ([email protected])
Mostra file Open project: alcaeus/mongo-php-adapter Class Usage Examples

Public Properties

Property Type Description
$file array

Protected Properties

Property Type Description
$gridfs

Public Methods

Method Description
__construct ( MongoGridFS $gridfs, array $file )
getBytes ( ) : string This will load the file into memory. If the file is bigger than your memory, this will cause problems!
getFilename ( ) : string Returns this file's filename
getResource ( ) : resource This method returns a stream resource that can be used to read the stored file with all file functions in PHP.
getSize ( ) : integer Returns this file's size
write ( string $filename = null ) : integer Writes this file to the filesystem

Private Methods

Method Description
copyToResource ( $handle )
getChunks ( )

Method Details

__construct() public method

public __construct ( MongoGridFS $gridfs, array $file )
$gridfs MongoGridFS The parent MongoGridFS instance
$file array A file from the database

getBytes() public method

This will load the file into memory. If the file is bigger than your memory, this will cause problems!
public getBytes ( ) : string
return string Returns a string of the bytes in the file

getFilename() public method

Returns this file's filename
public getFilename ( ) : string
return string Returns the filename

getResource() public method

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.
public getResource ( ) : resource
return resource Returns a resource that can be used to read the file with

getSize() public method

Returns this file's size
public getSize ( ) : integer
return integer Returns this file's size

write() public method

Writes this file to the filesystem
public write ( string $filename = null ) : integer
$filename string The location to which to write the file (path+filename+extension). If none is given, the stored filename will be used.
return integer Returns the number of bytes written

Property Details

$file public_oe property

public array $file
return array

$gridfs protected_oe property

protected $gridfs