diff --git a/source/reference/class/MongoDBGridFSBucket.txt b/source/reference/class/MongoDBGridFSBucket.txt index e3b39944..ab7f42b4 100644 --- a/source/reference/class/MongoDBGridFSBucket.txt +++ b/source/reference/class/MongoDBGridFSBucket.txt @@ -35,6 +35,7 @@ Methods __construct() delete() + deleteByName() downloadToStream() downloadToStreamByName() drop() @@ -56,10 +57,12 @@ Methods openUploadStream() registerGlobalStreamWrapperAlias() rename() + renameByName() uploadFromStream() - :phpmethod:`MongoDB\GridFS\Bucket::__construct()` - :phpmethod:`MongoDB\GridFS\Bucket::delete()` +- :phpmethod:`MongoDB\GridFS\Bucket::deleteByName()` - :phpmethod:`MongoDB\GridFS\Bucket::downloadToStream()` - :phpmethod:`MongoDB\GridFS\Bucket::drop()` - :phpmethod:`MongoDB\GridFS\Bucket::find()` @@ -80,4 +83,5 @@ Methods - :phpmethod:`MongoDB\GridFS\Bucket::openUploadStream()` - :phpmethod:`MongoDB\GridFS\Bucket::registerGlobalStreamWrapperAlias()` - :phpmethod:`MongoDB\GridFS\Bucket::rename()` +- :phpmethod:`MongoDB\GridFS\Bucket::renameByName()` - :phpmethod:`MongoDB\GridFS\Bucket::uploadFromStream()` diff --git a/source/reference/method/MongoDBGridFSBucket-deleteByName.txt b/source/reference/method/MongoDBGridFSBucket-deleteByName.txt new file mode 100644 index 00000000..70fcb5a1 --- /dev/null +++ b/source/reference/method/MongoDBGridFSBucket-deleteByName.txt @@ -0,0 +1,50 @@ +======================================= +MongoDB\\GridFS\\Bucket::deleteByName() +======================================= + + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Definition +---------- + +.. phpmethod:: MongoDB\GridFS\Bucket::deleteByName() + + Deletes a file and all its revisions from the GridFS bucket. + + .. code-block:: php + + function deleteByName(string $filename): void + +Parameters +---------- + +``$filename`` : string + The ``filename`` of the files to delete. + +Errors/Exceptions +----------------- + +.. include:: /includes/extracts/error-gridfs-filenotfoundexception.rst +.. include:: /includes/extracts/error-driver-runtimeexception.rst + +Examples +-------- + +.. code-block:: php + + test->selectGridFSBucket(); + + $stream = fopen('php://temp', 'w+b'); + fwrite($stream, "foobar"); + rewind($stream); + + $bucket->uploadFromStream('filename', $stream); + + $bucket->deleteByName('filename'); \ No newline at end of file diff --git a/source/reference/method/MongoDBGridFSBucket-renameByName.txt b/source/reference/method/MongoDBGridFSBucket-renameByName.txt new file mode 100644 index 00000000..ef351c27 --- /dev/null +++ b/source/reference/method/MongoDBGridFSBucket-renameByName.txt @@ -0,0 +1,62 @@ +======================================= +MongoDB\\GridFS\\Bucket::renameByName() +======================================= + + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Definition +---------- + +.. phpmethod:: MongoDB\GridFS\Bucket::renameByName() + + Sets a new ``filename`` value for a GridFS file and any of its + revisions. + + .. code-block:: php + + function renameByName(string $filename, string $newFilename): void + +Parameters +---------- + +``$filename`` : string + The ``filename`` of the files to rename. + +``$newFilename`` : string + The new ``filename`` value. + +Errors/Exceptions +----------------- + +.. include:: /includes/extracts/error-gridfs-filenotfoundexception.rst +.. include:: /includes/extracts/error-driver-runtimeexception.rst + +Examples +-------- + +.. code-block:: php + + test->selectGridFSBucket(); + + $stream = fopen('php://temp', 'w+b'); + fwrite($stream, "foobar"); + rewind($stream); + + $bucket->uploadFromStream('a', $stream); + + $bucket->renameByName('a', 'b'); + + var_dump(stream_get_contents($bucket->openDownloadStreamByName('b'))); + +The output would then resemble: + +.. code-block:: none + + string(6) "foobar" diff --git a/source/write/gridfs.txt b/source/write/gridfs.txt index 1cac77cb..5377ab93 100644 --- a/source/write/gridfs.txt +++ b/source/write/gridfs.txt @@ -449,4 +449,6 @@ see the following API documentation: - :phpmethod:`MongoDB\GridFS\Bucket::openDownloadStream()` - :phpmethod:`MongoDB\GridFS\Bucket::downloadToStream()` - :phpmethod:`MongoDB\GridFS\Bucket::rename()` -- :phpmethod:`MongoDB\GridFS\Bucket::delete()` \ No newline at end of file +- :phpmethod:`MongoDB\GridFS\Bucket::renameByName()` +- :phpmethod:`MongoDB\GridFS\Bucket::delete()` +- :phpmethod:`MongoDB\GridFS\Bucket::deleteByName()` \ No newline at end of file