Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions source/reference/class/MongoDBGridFSBucket.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Methods

__construct() </reference/method/MongoDBGridFSBucket__construct>
delete() </reference/method/MongoDBGridFSBucket-delete>
deleteByName() </reference/method/MongoDBGridFSBucket-deleteByName>
downloadToStream() </reference/method/MongoDBGridFSBucket-downloadToStream>
downloadToStreamByName() </reference/method/MongoDBGridFSBucket-downloadToStreamByName>
drop() </reference/method/MongoDBGridFSBucket-drop>
Expand All @@ -56,10 +57,12 @@ Methods
openUploadStream() </reference/method/MongoDBGridFSBucket-openUploadStream>
registerGlobalStreamWrapperAlias() </reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias>
rename() </reference/method/MongoDBGridFSBucket-rename>
renameByName() </reference/method/MongoDBGridFSBucket-renameByName>
uploadFromStream() </reference/method/MongoDBGridFSBucket-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()`
Expand All @@ -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()`
50 changes: 50 additions & 0 deletions source/reference/method/MongoDBGridFSBucket-deleteByName.txt
Original file line number Diff line number Diff line change
@@ -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

<?php

$bucket = (new MongoDB\Client)->test->selectGridFSBucket();

$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);

$bucket->uploadFromStream('filename', $stream);

$bucket->deleteByName('filename');
62 changes: 62 additions & 0 deletions source/reference/method/MongoDBGridFSBucket-renameByName.txt
Original file line number Diff line number Diff line change
@@ -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()

Selects a GridFS file and any of its revisions by their ``filename``
and sets a new ``filename`` value.

.. 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

<?php

$bucket = (new MongoDB\Client)->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"
4 changes: 3 additions & 1 deletion source/write/gridfs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()`
- :phpmethod:`MongoDB\GridFS\Bucket::renameByName()`
- :phpmethod:`MongoDB\GridFS\Bucket::delete()`
- :phpmethod:`MongoDB\GridFS\Bucket::deleteByName()`
Loading