- Reference >
- MongoDB\Database Class >
- MongoDB\Database::selectGridFSBucket()
MongoDB\Database::selectGridFSBucket()
On this page
Definition
-
MongoDB\Database::selectGridFSBucket
Selects a GridFS bucket within the database.
This method has the following parameters:
Parameter Type Description $options
array Optional. An array specifying the desired options. The
$options
parameter supports the following options:Option Type Description bucketName
string Optional. The bucket name, which will be used as a prefix for the files and chunks collections. Defaults to "fs"
.chunkSizeBytes
integer Optional. The chunk size in bytes. Defaults to 261120
(i.e. 255 KiB).readConcern
MongoDB\Driver\ReadConcern Optional. The default read concern to use for bucket operations. Defaults to the database’s read concern. readPreference
MongoDB\Driver\ReadPreference Optional. The default read preference to use for bucket operations. Defaults to the database’s read preference. typeMap
array Optional. The type map to apply to cursors, which determines how BSON documents are converted to PHP values. Defaults to the database’s type map. writeConcern
MongoDB\Driver\WriteConcern Optional. The default write concern to use for bucket operations. Defaults to the database’s write concern.
Return Values
A MongoDB\GridFS\Bucket
object.
Errors/Exceptions
MongoDB\Exception\InvalidArgumentException
for errors related to
the parsing of parameters or options.
Behavior
The selected bucket inherits options such as read preference and type
mapping from the Database
object. Options may be
overridden via the $options
parameter.
Example
The following example selects the default fs.files
bucket in the test
database:
The following example selects the custom images.files
bucket in the test
database with a custom read preference: