MongoDB\GridFS\Bucket Class
For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt
MongoDB\GridFS\Bucket Class
Definition
GridFS is a specification for storing and retrieving files in MongoDB. GridFS uses two collections to store files. One collection stores the file chunks (e.g. fs.chunks), and the other stores file metadata (e.g. fs.files). The [MongoDB\GridFS\Bucket](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbgridfsbucket.md#mongodb-phpclass-phpclass.MongoDB-GridFS-Bucket class provides an interface around these collections for working with the files as PHP Streams.
You can construct a GridFS bucket using the extension's Manager class, or get access to a bucket from the library's [MongoDB\Database](https://www.mongodb.com/docs/php-library/current/reference/class/mongodbdatabase.md#mongodb-phpclass-phpclass.MongoDB-Database class via the [getGridFSBucket()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbdatabase-getgridfsbucket.md#mongodb-phpmethod-phpmethod.MongoDB-Database--getGridFSBucket-- method.
Methods
-
[
MongoDB\GridFS\Bucket::__construct()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket__construct.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--__construct-- -
[
MongoDB\GridFS\Bucket::delete()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-delete.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--delete-- -
[
MongoDB\GridFS\Bucket::deleteByName()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-deletebyname.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--deleteByName-- -
[
MongoDB\GridFS\Bucket::downloadToStream()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-downloadtostream.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--downloadToStream-- -
[
MongoDB\GridFS\Bucket::drop()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-drop.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--drop-- -
[
MongoDB\GridFS\Bucket::find()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-find.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--find-- -
[
MongoDB\GridFS\Bucket::findOne()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-findone.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--findOne-- -
[
MongoDB\GridFS\Bucket::getBucketName()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getbucketname.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getBucketName-- -
[
MongoDB\GridFS\Bucket::getChunksCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getchunkscollection.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getChunksCollection-- -
[
MongoDB\GridFS\Bucket::getChunkSizeBytes()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getchunksizebytes.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getChunkSizeBytes-- -
[
MongoDB\GridFS\Bucket::getDatabaseName()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getdatabasename.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getDatabaseName-- -
[
MongoDB\GridFS\Bucket::getFileDocumentForStream()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getfiledocumentforstream.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getFileDocumentForStream-- -
[
MongoDB\GridFS\Bucket::getFileIdForStream()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getfileidforstream.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getFileIdForStream-- -
[
MongoDB\GridFS\Bucket::getFilesCollection()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getfilescollection.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getFilesCollection-- -
[
MongoDB\GridFS\Bucket::getReadConcern()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getreadconcern.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getReadConcern-- -
[
MongoDB\GridFS\Bucket::getReadPreference()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getreadpreference.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getReadPreference-- -
[
MongoDB\GridFS\Bucket::getTypeMap()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-gettypemap.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getTypeMap-- -
[
MongoDB\GridFS\Bucket::getWriteConcern()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-getwriteconcern.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--getWriteConcern-- -
[
MongoDB\GridFS\Bucket::openDownloadStream()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-opendownloadstream.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--openDownloadStream-- -
[
MongoDB\GridFS\Bucket::openDownloadStreamByName()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-opendownloadstreambyname.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--openDownloadStreamByName-- -
[
MongoDB\GridFS\Bucket::openUploadStream()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-openuploadstream.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--openUploadStream-- -
[
MongoDB\GridFS\Bucket::registerGlobalStreamWrapperAlias()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-registerglobalstreamwrapperalias.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--registerGlobalStreamWrapperAlias-- -
[
MongoDB\GridFS\Bucket::rename()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-rename.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--rename-- -
[
MongoDB\GridFS\Bucket::renameByName()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-renamebyname.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--renameByName-- -
[
MongoDB\GridFS\Bucket::uploadFromStream()](https://www.mongodb.com/docs/php-library/current/reference/method/mongodbgridfsbucket-uploadfromstream.md#mongodb-phpmethod-phpmethod.MongoDB-GridFS-Bucket--uploadFromStream--
