PHP Class Phalcon\Db\Adapter\MongoDB\GridFS\Bucket

Datei anzeigen Open project: phalcon/incubator

Public Methods

Method Description
__construct ( MongoDB\Driver\Manager $manager, string $databaseName, array $options = [] ) Constructs a GridFS bucket.
delete ( mixed $id ) Delete a file from the GridFS bucket.
downloadToStream ( mixed $id, resource $destination ) Writes the contents of a GridFS file to a writable stream.
downloadToStreamByName ( string $filename, resource $destination, array $options = [] ) Writes the contents of a GridFS file, which is selected by name and revision, to a writable stream.
drop ( ) Drops the files and chunks collections associated with this GridFS bucket.
find ( array | object $filter, array $options = [] ) : MongoDB\Driver\Cursor Finds documents from the GridFS bucket's files collection matching the query.
getCollectionWrapper ( )
getDatabaseName ( )
getIdFromStream ( resource $stream ) : mixed Gets the ID of the GridFS file associated with a stream.
openDownloadStream ( mixed $id ) : resource Opens a readable stream for reading a GridFS file.
openDownloadStreamByName ( string $filename, array $options = [] ) : resource Opens a readable stream stream to read a GridFS file, which is selected by name and revision.
openUploadStream ( string $filename, array $options = [] ) : resource Opens a writable stream for writing a GridFS file.
rename ( mixed $id, string $newFilename ) Renames the GridFS file with the specified ID.
uploadFromStream ( string $filename, resource $source, array $options = [] ) : MongoDB\BSON\ObjectId Writes the contents of a readable stream to a GridFS file.

Private Methods

Method Description
createPathForFile ( stdClass $file ) : string Creates a path for an existing GridFS file.
createPathForUpload ( ) : string Creates a path for a new GridFS file, which does not yet have an ID.
getFilesNamespace ( ) : string Returns the names of the files collection.
openDownloadStreamByFile ( stdClass $file ) : resource Opens a readable stream for the GridFS file.
registerStreamWrapper ( ) Registers the GridFS stream wrapper if it is not already registered.

Method Details

__construct() public method

Supported options: * bucketName (string): The bucket name, which will be used as a prefix for the files and chunks collections. Defaults to "fs". * chunkSizeBytes (integer): The chunk size in bytes. Defaults to 261120 (i.e. 255 KiB). * readPreference (MongoDB\Driver\ReadPreference): Read preference. * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
public __construct ( MongoDB\Driver\Manager $manager, string $databaseName, array $options = [] )
$manager MongoDB\Driver\Manager Manager instance from the driver
$databaseName string Database name
$options array Bucket options

delete() public method

If the files collection document is not found, this method will still attempt to delete orphaned chunks.
public delete ( mixed $id )
$id mixed File ID

downloadToStream() public method

Writes the contents of a GridFS file to a writable stream.
public downloadToStream ( mixed $id, resource $destination )
$id mixed File ID
$destination resource Writable Stream

downloadToStreamByName() public method

Supported options: * revision (integer): Which revision (i.e. documents with the same filename and different uploadDate) of the file to retrieve. Defaults to -1 (i.e. the most recent revision). Revision numbers are defined as follows: * 0 = the original stored file * 1 = the first revision * 2 = the second revision * etc… * -2 = the second most recent revision * -1 = the most recent revision
public downloadToStreamByName ( string $filename, resource $destination, array $options = [] )
$filename string Filename
$destination resource Writable Stream
$options array Download options

drop() public method

Drops the files and chunks collections associated with this GridFS bucket.
public drop ( )

find() public method

Finds documents from the GridFS bucket's files collection matching the query.
See also: Find::__construct() for supported options
public find ( array | object $filter, array $options = [] ) : MongoDB\Driver\Cursor
$filter array | object Query by which to filter documents
$options array Additional options
return MongoDB\Driver\Cursor

getCollectionWrapper() public method

getDatabaseName() public method

public getDatabaseName ( )

getIdFromStream() public method

Gets the ID of the GridFS file associated with a stream.
public getIdFromStream ( resource $stream ) : mixed
$stream resource GridFS stream
return mixed

openDownloadStream() public method

Opens a readable stream for reading a GridFS file.
public openDownloadStream ( mixed $id ) : resource
$id mixed File ID
return resource

openDownloadStreamByName() public method

Supported options: * revision (integer): Which revision (i.e. documents with the same filename and different uploadDate) of the file to retrieve. Defaults to -1 (i.e. the most recent revision). Revision numbers are defined as follows: * 0 = the original stored file * 1 = the first revision * 2 = the second revision * etc… * -2 = the second most recent revision * -1 = the most recent revision
public openDownloadStreamByName ( string $filename, array $options = [] ) : resource
$filename string Filename
$options array Download options
return resource

openUploadStream() public method

Supported options: * chunkSizeBytes (integer): The chunk size in bytes. Defaults to the bucket's chunk size.
public openUploadStream ( string $filename, array $options = [] ) : resource
$filename string Filename
$options array Upload options
return resource

rename() public method

Renames the GridFS file with the specified ID.
public rename ( mixed $id, string $newFilename )
$id mixed File ID
$newFilename string New filename

uploadFromStream() public method

Supported options: * chunkSizeBytes (integer): The chunk size in bytes. Defaults to the bucket's chunk size.
public uploadFromStream ( string $filename, resource $source, array $options = [] ) : MongoDB\BSON\ObjectId
$filename string Filename
$source resource Readable stream
$options array Stream options
return MongoDB\BSON\ObjectId ID of the newly created GridFS file