Commit 4955333a authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-221: API documentation for MongoDB\GridFS\Bucket

parent b33e5a5a
arg_name: option
name: bucketName
type: string
description: |
The bucket name, which will be used as a prefix for the files and chunks
collections. Defaults to ``"fs"``.
interface: phpmethod
operation: MongoDB\\Database::selectGridFSBucket
optional: true
position: 1
---
arg_name: option
name: chunkSizeBytes
type: integer
description: |
The chunk size in bytes. Defaults to ``261120`` (i.e. 255 KiB).
interface: phpmethod
operation: MongoDB\\Database::selectGridFSBucket
optional: true
position: 2
---
source:
file: apiargs-common-option.yaml
ref: readConcern
operation: MongoDB\\Database::selectGridFSBucket
position: 3
replacement:
resource: "bucket"
parent: "database"
---
source:
file: apiargs-common-option.yaml
ref: readPreference
operation: MongoDB\\Database::selectGridFSBucket
position: 4
replacement:
resource: "bucket"
parent: "database"
---
source:
file: apiargs-common-option.yaml
ref: writeConcern
operation: MongoDB\\Database::selectGridFSBucket
position: 5
replacement:
resource: "bucket"
parent: "database"
...
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\Database::selectGridFSBucket
position: 1
...
arg_name: option
name: bucketName
type: string
description: |
The bucket name, which will be used as a prefix for the files and chunks
collections. Defaults to ``"fs"``.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::__construct
optional: true
position: 1
---
arg_name: option
name: chunkSizeBytes
type: integer
description: |
The chunk size in bytes. Defaults to ``261120`` (i.e. 255 KiB).
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::__construct
optional: true
position: 2
---
source:
file: apiargs-common-option.yaml
ref: readConcern
operation: MongoDB\\GridFS\\Bucket::__construct
position: 3
replacement:
resource: "bucket"
parent: "database"
---
source:
file: apiargs-common-option.yaml
ref: readPreference
operation: MongoDB\\GridFS\\Bucket::__construct
position: 4
replacement:
resource: "bucket"
parent: "database"
---
source:
file: apiargs-common-option.yaml
ref: writeConcern
operation: MongoDB\\GridFS\\Bucket::__construct
position: 5
replacement:
resource: "bucket"
parent: "database"
...
source:
file: apiargs-common-param.yaml
ref: $manager
operation: MongoDB\\GridFS\\Bucket::__construct
position: 1
---
source:
file: apiargs-common-param.yaml
ref: $databaseName
operation: MongoDB\\GridFS\\Bucket::__construct
position: 2
---
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\GridFS\\Bucket::__construct
position: 3
...
arg_name: param
name: $id
type: mixed
description: |
The ``_id`` of the file to delete.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::delete
optional: false
position: 1
...
arg_name: param
name: $id
type: mixed
description: |
The ``_id`` of the file to download.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::downloadToStream
optional: false
position: 1
---
arg_name: param
name: $destination
type: resource
description: |
Writable stream where the GridFS file's contents will be written.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::downloadToStream
optional: false
position: 2
...
arg_name: option
name: revision
type: integer
description: |
The revision of the file to retrieve. Files with the name ``filename`` will be
differentiated by their ``uploadDate`` field.
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
Defaults to -1 (i.e. the most recent revision).
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::downloadToStreamByName
optional: true
position: 1
...
arg_name: param
name: $filename
type: string
description: |
The ``filename`` of the file to download.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::downloadToStreamByName
optional: false
position: 1
---
arg_name: param
name: $destination
type: resource
description: |
Writable stream where the GridFS file's contents will be written.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::downloadToStreamByName
optional: false
position: 2
---
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\GridFS\\Bucket::downloadToStreamByName
position: 3
...
arg_name: param
name: $stream
type: resource
description: |
The GridFS stream resource.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::getFileDocumentForStream
optional: false
position: 1
...
arg_name: param
name: $stream
type: resource
description: |
The GridFS stream resource.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::getFileIdForStream
optional: false
position: 1
...
arg_name: param
name: $id
type: mixed
description: |
The ``_id`` of the file to download.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openDownloadStream
optional: false
position: 1
...
arg_name: option
name: revision
type: integer
description: |
The revision of the file to retrieve. Files with the name ``filename`` will be
differentiated by their ``uploadDate`` field.
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
Defaults to -1 (i.e. the most recent revision).
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openDownloadStreamByName
optional: true
position: 1
...
arg_name: param
name: $filename
type: string
description: |
The ``filename`` of the file to download.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openDownloadStreamByName
optional: false
position: 1
---
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\GridFS\\Bucket::openDownloadStreamByName
position: 2
...
arg_name: option
name: _id
type: mixed
description: |
Value to use as the file document identifier. Defaults to a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openUploadStream
optional: true
position: 1
---
arg_name: option
name: chunkSizeBytes
type: integer
description: |
The chunk size in bytes. Defaults to the bucket's ``chunkSizeBytes`` option.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openUploadStream
optional: true
position: 2
---
arg_name: option
name: metadata
type: array|object
description: |
User data for the ``metadata`` field of the file document. If not specified,
the ``metadata`` field will not be set on the file document.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openUploadStream
optional: true
position: 3
...
arg_name: param
name: $filename
type: string
description: |
The ``filename`` of the file to create.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::openUploadStream
optional: false
position: 1
---
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\GridFS\\Bucket::openUploadStream
position: 2
...
arg_name: param
name: $id
type: mixed
description: |
The ``_id`` of the file to rename.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::rename
optional: false
position: 1
---
arg_name: param
name: $newFilename
type: string
description: |
The new ``filename`` value.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::rename
optional: false
position: 2
...
arg_name: option
name: _id
type: mixed
description: |
Value to use as the file document identifier. Defaults to a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::uploadFromStream
optional: true
position: 1
---
arg_name: option
name: chunkSizeBytes
type: integer
description: |
The chunk size in bytes. Defaults to the bucket's ``chunkSizeBytes`` option.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::uploadFromStream
optional: true
position: 2
---
arg_name: option
name: metadata
type: array|object
description: |
User data for the ``metadata`` field of the file document. If not specified,
the ``metadata`` field will not be set on the file document.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::uploadFromStream
optional: true
position: 3
...
arg_name: param
name: $filename
type: string
description: |
The ``filename`` of the file to create.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::uploadFromStream
optional: false
position: 1
---
arg_name: param
name: $source
type: resource
description: |
Readable stream where the file's contents will be read.
interface: phpmethod
operation: MongoDB\\GridFS\\Bucket::uploadFromStream
optional: false
position: 2
---
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\GridFS\\Bucket::uploadFromStream
position: 3
...
...@@ -11,3 +11,4 @@ Reference ...@@ -11,3 +11,4 @@ Reference
/reference/class/MongoDBClient /reference/class/MongoDBClient
/reference/class/MongoDBDatabase /reference/class/MongoDBDatabase
/reference/class/MongoDBCollection /reference/class/MongoDBCollection
/reference/class/MongoDBGridFSBucket
...@@ -54,5 +54,6 @@ Methods ...@@ -54,5 +54,6 @@ Methods
/reference/method/MongoDBDatabase-getManager /reference/method/MongoDBDatabase-getManager
/reference/method/MongoDBDatabase-listCollections /reference/method/MongoDBDatabase-listCollections
/reference/method/MongoDBDatabase-selectCollection /reference/method/MongoDBDatabase-selectCollection
/reference/method/MongoDBDatabase-selectGridFSBucket
/reference/method/MongoDBDatabase-withOptions /reference/method/MongoDBDatabase-withOptions
============================
MongoDB\\GridFS\Bucket Class
============================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpclass:: MongoDB\\GridFS\\Bucket
:manual:`GridFS </core/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 :phpclass:`MongoDB\\GridFS\\Bucket`
class provides an interface around these collections for working with the
files as PHP :php:`Streams <stream>`.
You can construct a GridFS bucket using the PHP extension's
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` class, or
select a bucket from the |php-library|'s :phpclass:`MongoDB\\Database` class
via the :phpmethod:`selectGridFSBucket()
<MongoDB\\Database::selectGridFSBucket>` method.
Methods
-------
.. toctree::
:titlesonly:
/reference/method/MongoDBGridFSBucket__construct
/reference/method/MongoDBGridFSBucket-delete
/reference/method/MongoDBGridFSBucket-downloadToStream
/reference/method/MongoDBGridFSBucket-downloadToStreamByName
/reference/method/MongoDBGridFSBucket-drop
/reference/method/MongoDBGridFSBucket-find
/reference/method/MongoDBGridFSBucket-getBucketName
/reference/method/MongoDBGridFSBucket-getDatabaseName
/reference/method/MongoDBGridFSBucket-getFileDocumentForStream
/reference/method/MongoDBGridFSBucket-getFileIdForStream
/reference/method/MongoDBGridFSBucket-openDownloadStream
/reference/method/MongoDBGridFSBucket-openDownloadStreamByName
/reference/method/MongoDBGridFSBucket-openUploadStream
/reference/method/MongoDBGridFSBucket-rename
/reference/method/MongoDBGridFSBucket-uploadFromStream
=======================================
MongoDB\\Database::selectGridFSBucket()
=======================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\Database::selectGridFSBucket()
Selects a GridFS bucket within the database.
.. code-block:: php
function selectGridFSBucket(array $options = []): MongoDB\GridFS\Bucket
:phpmethod:`MongoDB\\Database::selectGridFSBucket()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-selectGridFSBucket-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-selectGridFSBucket-option.rst
:returns:
A :phpclass:`MongoDB\\GridFS\\Bucket` object.
Behavior
--------
The selected bucket inherits options such as read preference and write concern
from the :phpclass:`Database <MongoDB\\Database>` object. Options may be
overridden via the ``$options`` parameter.
Example
-------
The following example selects the default ``fs.files`` bucket in the ``demo``
database:
.. code-block:: php
<?php
$db = (new MongoDB\Client)->demo;
$bucket = $db->selectGridFSBucket();
The following example selects the custom ``images.files`` bucket in the ``demo``
database with a custom read preference:
.. code-block:: php
<?php
$db = (new MongoDB\Client)->demo;
$imagesBucket = $db->selectGridFSBucket([
'bucketName' => 'images',
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
]);
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::__construct()`
=================================
MongoDB\\GridFS\\Bucket::delete()
=================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::delete()
Delete a file and its chunks from the GridFS bucket.
.. code-block:: php
function delete($id): void
:phpmethod:`MongoDB\\GridFS\\Bucket::delete()` has the following parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-delete-param.rst
Behavior
--------
If the files collection document is not found, this method will still attempt to
delete orphaned chunks.
.. todo: add examples
===========================================
MongoDB\\GridFS\\Bucket::downloadToStream()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::downloadToStream()
Selects a GridFS file by its ``_id`` and copies its contents to a writable
stream.
.. code-block:: php
function downloadToStream($id, $destination): void
:phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-downloadToStream-param.rst
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
===========================================
MongoDB\\GridFS\\Bucket::downloadToStream()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::downloadToStreamByName()
Selects a GridFS file by its ``filename`` and copies its contents to a
writable stream.
.. code-block:: php
function downloadToStreamByName($filename, $destination, array $options = []): void
:phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()` has the
following parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-downloadToStreamByName-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-downloadToStreamByName-option.rst
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
===============================
MongoDB\\GridFS\\Bucket::drop()
===============================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::drop()
Drops the files and chunks collections associated with this GridFS bucket.
.. code-block:: php
function drop(): void
.. todo: add examples
===============================
MongoDB\\GridFS\\Bucket::find()
===============================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::find()
Finds documents from the GridFS bucket's files collection matching the query.
.. code-block:: php
function find($filter = [], array $options = []): MongoDB\Driver\Cursor
:phpmethod:`MongoDB\\GridFS\\Bucket::find()` has the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-find-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBCollection-method-find-option.rst
:returns:
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\Collection::find()`
===========================================
MongoDB\\GridFS\\Bucket::downloadToStream()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::getBucketName()
Returns the name of this bucket.
.. code-block:: php
function getBucketName(): string
:returns:
The name of this bucket as a string.
.. todo: add examples
==========================================
MongoDB\\GridFS\\Bucket::getDatabaseName()
==========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::getDatabaseName()
Returns the name of the database containing this bucket.
.. code-block:: php
function getDatabaseName(): string
:returns:
The name of the database containing this bucket as a string.
.. todo: add examples
===================================================
MongoDB\\GridFS\\Bucket::getFileDocumentForStream()
===================================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::getFileDocumentForStream()
Gets the file document of the GridFS file associated with a stream.
.. code-block:: php
function getFileDocumentForStream($stream): object
:phpmethod:`MongoDB\\GridFS\\Bucket::getFileDocumentForStream()` has the
following parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-getFileDocumentForStream-param.rst
:returns:
The metadata document associated with the GridFS stream.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::getFileIdForStream()`
=============================================
MongoDB\\GridFS\\Bucket::getFileIdForStream()
=============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::getFileIdForStream()
Gets the file document's ID of the GridFS file associated with a stream.
.. code-block:: php
function getFileIdForStream($stream): mixed
:phpmethod:`MongoDB\\GridFS\\Bucket::getFileIdForStream()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-getFileIdForStream-param.rst
:returns:
The ``_id`` field of the metadata document associated with the GridFS
stream.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::getFileDocumentForStream()`
=============================================
MongoDB\\GridFS\\Bucket::openDownloadStream()
=============================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::openDownloadStream()
Selects a GridFS file by its ``_id`` and opens it as a readable stream.
.. code-block:: php
function openDownloadStream($id): resource
:phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openDownloadStream-param.rst
:returns:
A readable stream resource.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()`
===================================================
MongoDB\\GridFS\\Bucket::openDownloadStreamByName()
===================================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::openDownloadStreamByName()
Selects a GridFS file by its ``filename`` and opens it as a readable stream.
.. code-block:: php
function openDownloadStreamByName($filename, array $options = []): resource
:phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStreamByName()` has the
following parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openDownloadStreamByName-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openDownloadStreamByName-option.rst
:returns:
A readable stream resource.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStream()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::downloadToStreamByName()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::openDownloadStream()`
===========================================
MongoDB\\GridFS\\Bucket::openUploadStream()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::openUploadStream()
Opens a writable stream for a new GridFS file.
.. code-block:: php
function openUploadStream($filename, array $options = []): resource
:phpmethod:`MongoDB\\GridFS\\Bucket::openUploadStream()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openUploadStream-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-openUploadStream-option.rst
:returns:
A writable stream resource.
Behavior
--------
Chunk documents will be created as data is written to the writable stream. The
metadata document will be created when the writable stream is closed.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::uploadFromStream()`
=================================
MongoDB\\GridFS\\Bucket::rename()
=================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::rename()
Selects a GridFS file by its ``_id`` and alters its ``filename``.
.. code-block:: php
function rename($id, $newFilename): void
:phpmethod:`MongoDB\\GridFS\\Bucket::rename()` has the following parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-rename-param.rst
.. todo: add examples
===========================================
MongoDB\\GridFS\\Bucket::uploadFromStream()
===========================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::uploadFromStream()
Creates a new GridFS file and copies the contents of a readable stream to it.
.. code-block:: php
function uploadFromStream($filename, $source, array $options = []): mixed
:phpmethod:`MongoDB\\GridFS\\Bucket::uploadFromStream()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-uploadFromStream-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-uploadFromStream-option.rst
:returns:
The ``_id`` field of the metadata document associated with the newly
created GridFS file. If the ``_id`` option is not specified, a new
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object will
be used by default.
.. todo: add examples
.. seealso::
- :phpmethod:`MongoDB\\GridFS\\Bucket::openUploadStream()`
======================================
MongoDB\\GridFS\\Bucket::__construct()
======================================
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\\GridFS\\Bucket::__construct()
Constructs a new :phpclass:`Bucket <MongoDB\\GridFS\\Bucket>` instance.
.. code-block:: php
function __construct(MongoDB\Driver\Manager $manager, $databaseName, $collectionName, array $options = [])
:phpmethod:`MongoDB\\GridFS\\Bucket::__construct()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-construct-param.rst
The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-construct-option.rst
Behavior
--------
If you construct a Bucket explicitly, the Bucket inherits any options
from the :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
If you select the Bucket from a :phpclass:`Database <MongoDB\\Database>` object,
the Bucket inherits its options from that object.
.. todo: add an example
.. seealso::
- :phpmethod:`MongoDB\\Database::selectGridFSBucket()`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment