Skip to content

Commit d2eba6e

Browse files
authored
PHPLIB-1323 Implement unlink for GridFS stream wrapper (#1206)
* Delete all file revisions by bulk * Thrown a FileNotFoundException in rename and unlink * Fix rename with same file name
1 parent 63fb985 commit d2eba6e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

source/reference/method/MongoDBGridFSBucket-registerGlobalStreamWrapperAlias.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ Supported stream functions:
4848
- :php:`filesize() <filesize>`
4949
- :php:`file() <file>`
5050
- :php:`fopen() <fopen>` with "r", "rb", "w", and "wb" modes
51-
- :php:`rename() <rename>` rename all revisions of a file in the same bucket
51+
- :php:`rename() <rename>`
52+
- :php:`unlink() <unlink>`
5253

5354
In read mode, the stream context can contain the option ``gridfs['revision']``
5455
to specify the revision number of the file to read. If omitted, the most recent
@@ -57,6 +58,9 @@ revision is read (revision ``-1``).
5758
In write mode, the stream context can contain the option ``gridfs['chunkSizeBytes']``.
5859
If omitted, the defaults are inherited from the ``Bucket`` instance option.
5960

61+
The functions `rename` and `unlink` will rename or remove all revisions of a
62+
filename. If the filename does not exist, these functions throw a ``FileNotFoundException``.
63+
6064
Example
6165
-------
6266

@@ -86,6 +90,8 @@ Each call to these functions makes a request to the server.
8690

8791
echo file_get_contents('gridfs://mybucket/hello.txt');
8892

93+
unlink('gridfs://mybucket/hello.txt');
94+
8995
The output would then resemble:
9096

9197
.. code-block:: none

0 commit comments

Comments
 (0)