Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
f812b9e6
Commit
f812b9e6
authored
Apr 19, 2018
by
Katherine Walker
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #527
parents
b9f35916
9c65561d
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
422 additions
and
21 deletions
+422
-21
MongoDBGridFSBucket-delete.txt
docs/reference/method/MongoDBGridFSBucket-delete.txt
+16
-1
MongoDBGridFSBucket-downloadToStream.txt
...reference/method/MongoDBGridFSBucket-downloadToStream.txt
+25
-2
MongoDBGridFSBucket-downloadToStreamByName.txt
...nce/method/MongoDBGridFSBucket-downloadToStreamByName.txt
+25
-2
MongoDBGridFSBucket-drop.txt
docs/reference/method/MongoDBGridFSBucket-drop.txt
+18
-1
MongoDBGridFSBucket-find.txt
docs/reference/method/MongoDBGridFSBucket-find.txt
+43
-1
MongoDBGridFSBucket-findOne.txt
docs/reference/method/MongoDBGridFSBucket-findOne.txt
+40
-1
MongoDBGridFSBucket-getBucketName.txt
docs/reference/method/MongoDBGridFSBucket-getBucketName.txt
+14
-1
MongoDBGridFSBucket-getChunkSizeBytes.txt
...eference/method/MongoDBGridFSBucket-getChunkSizeBytes.txt
+14
-1
MongoDBGridFSBucket-getChunksCollection.txt
...erence/method/MongoDBGridFSBucket-getChunksCollection.txt
+14
-1
MongoDBGridFSBucket-getDatabaseName.txt
.../reference/method/MongoDBGridFSBucket-getDatabaseName.txt
+15
-1
MongoDBGridFSBucket-getFileDocumentForStream.txt
...e/method/MongoDBGridFSBucket-getFileDocumentForStream.txt
+33
-1
MongoDBGridFSBucket-getFileIdForStream.txt
...ference/method/MongoDBGridFSBucket-getFileIdForStream.txt
+23
-1
MongoDBGridFSBucket-getFilesCollection.txt
...ference/method/MongoDBGridFSBucket-getFilesCollection.txt
+17
-1
MongoDBGridFSBucket-openDownloadStream.txt
...ference/method/MongoDBGridFSBucket-openDownloadStream.txt
+22
-1
MongoDBGridFSBucket-openDownloadStreamByName.txt
...e/method/MongoDBGridFSBucket-openDownloadStreamByName.txt
+20
-1
MongoDBGridFSBucket-openUploadStream.txt
...reference/method/MongoDBGridFSBucket-openUploadStream.txt
+19
-1
MongoDBGridFSBucket-rename.txt
docs/reference/method/MongoDBGridFSBucket-rename.txt
+22
-1
MongoDBGridFSBucket-uploadFromStream.txt
...reference/method/MongoDBGridFSBucket-uploadFromStream.txt
+23
-1
MongoDBGridFSBucket__construct.txt
docs/reference/method/MongoDBGridFSBucket__construct.txt
+19
-1
No files found.
docs/reference/method/MongoDBGridFSBucket-delete.txt
View file @
f812b9e6
...
...
@@ -37,4 +37,19 @@ Behavior
If the files collection document is not found, this method will still attempt to
delete orphaned chunks.
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$id = $bucket->uploadFromStream('filename', $stream);
$bucket->delete($id);
docs/reference/method/MongoDBGridFSBucket-downloadToStream.txt
View file @
f812b9e6
...
...
@@ -26,8 +26,6 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-downloadToStream-param.rst
.. todo: add examples
Errors/Exceptions
-----------------
...
...
@@ -35,6 +33,31 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.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);
$id = $bucket->uploadFromStream('filename', $stream);
$destination = fopen('php://temp', 'w+b');
$bucket->downloadToStream($id, $destination);
var_dump(stream_get_contents($destination, -1, 0));
The output would then resemble::
string(6) "foobar"
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-downloadToStreamByName.txt
View file @
f812b9e6
...
...
@@ -30,8 +30,6 @@ Definition
.. include:: /includes/apiargs/MongoDBGridFSBucket-method-downloadToStreamByName-option.rst
.. todo: add examples
Errors/Exceptions
-----------------
...
...
@@ -39,6 +37,31 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.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);
$destination = fopen('php://temp', 'w+b');
$bucket->downloadToStreamByName('filename', $destination);
var_dump(stream_get_contents($destination, -1, 0));
The output would then resemble::
string(6) "foobar"
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-drop.txt
View file @
f812b9e6
...
...
@@ -26,4 +26,21 @@ Errors/Exceptions
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$database = (new MongoDB\Client)->test;
$bucket = $database->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$bucket->uploadFromStream('filename', $stream);
$bucket->drop();
docs/reference/method/MongoDBGridFSBucket-find.txt
View file @
f812b9e6
...
...
@@ -46,7 +46,49 @@ Behavior
.. include:: /includes/extracts/note-bson-comparison.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$bucket->uploadFromStream('b', $stream);
$cursor = $bucket->find(
['length' => ['$lte' => 6]],
[
'projection' => [
'filename' => 1,
'length' => 1,
'_id' => 0,
],
'sort' => ['length' => -1],
]
);
var_dump($cursor->toArray());
The output would then resemble::
array(1) {
[0]=>
object(MongoDB\Model\BSONDocument)#3015 (1) {
["storage":"ArrayObject":private]=>
array(2) {
["filename"]=>
string(1) "b"
["length"]=>
int(6)
}
}
}
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-findOne.txt
View file @
f812b9e6
...
...
@@ -49,7 +49,46 @@ Behavior
.. include:: /includes/extracts/note-bson-comparison.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$bucket->uploadFromStream('b', $stream);
$fileDocument = $bucket->findOne(
['length' => ['$lte' => 6]],
[
'projection' => [
'filename' => 1,
'length' => 1,
'_id' => 0,
],
'sort' => ['length' => -1],
]
);
var_dump($fileDocument);
The output would then resemble::
object(MongoDB\Model\BSONDocument)#3004 (1) {
["storage":"ArrayObject":private]=>
array(2) {
["filename"]=>
string(1) "b"
["length"]=>
int(6)
}
}
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-getBucketName.txt
View file @
f812b9e6
...
...
@@ -26,4 +26,17 @@ Return Values
The name of this bucket as a string.
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket->getBucketName());
The output would then resemble::
string(2) "fs"
docs/reference/method/MongoDBGridFSBucket-getChunkSizeBytes.txt
View file @
f812b9e6
...
...
@@ -28,4 +28,17 @@ Return Values
The chunk size of this bucket in bytes.
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket->getChunkSizeBytes());
The output would then resemble::
int(261120)
docs/reference/method/MongoDBGridFSBucket-getChunksCollection.txt
View file @
f812b9e6
...
...
@@ -28,4 +28,17 @@ Return Values
A :phpclass:`MongoDB\\Collection` object for the chunks collection.
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump((string) $bucket->getChunksCollection());
The output would then resemble::
string(14) "test.fs.chunks"
docs/reference/method/MongoDBGridFSBucket-getDatabaseName.txt
View file @
f812b9e6
...
...
@@ -26,4 +26,18 @@ Return Values
The name of the database containing this bucket as a string.
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket->getDatabaseName());
The output would then resemble::
string(4) "test"
docs/reference/method/MongoDBGridFSBucket-getFileDocumentForStream.txt
View file @
f812b9e6
...
...
@@ -37,7 +37,39 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = $bucket->openUploadStream('filename');
$fileDocument = $bucket->getFileDocumentForStream($stream);
var_dump($fileDocument);
fclose($stream);
The output would then resemble::
object(MongoDB\Model\BSONDocument)#4956 (1) {
["storage":"ArrayObject":private]=>
array(3) {
["_id"]=>
object(MongoDB\BSON\ObjectId)#4955 (1) {
["oid"]=>
string(24) "5acfb05b7e21e83b5a29037c"
}
["chunkSize"]=>
int(261120)
["filename"]=>
string(8) "filename"
}
}
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-getFileIdForStream.txt
View file @
f812b9e6
...
...
@@ -38,7 +38,29 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = $bucket->openUploadStream('filename');
$id = $bucket->getFileIdForStream($stream);
var_dump($id);
fclose($stream);
The output would then resemble::
object(MongoDB\BSON\ObjectId)#3005 (1) {
["oid"]=>
string(24) "5acfb37d7e21e83cdb3e1583"
}
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-getFilesCollection.txt
View file @
f812b9e6
...
...
@@ -28,4 +28,20 @@ Return Values
A :phpclass:`MongoDB\\Collection` object for the files collection.
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$filesCollection = $bucket->getFilesCollection();
var_dump($filesCollection->getCollectionName());
The output would then resemble::
string(8) "fs.files"
docs/reference/method/MongoDBGridFSBucket-openDownloadStream.txt
View file @
f812b9e6
...
...
@@ -36,7 +36,28 @@ Errors/Exceptions
.. include:: /includes/extracts/error-gridfs-filenotfoundexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$uploadStream = fopen('php://temp', 'w+b');
fwrite($uploadStream, "foobar");
rewind($uploadStream);
$id = $bucket->uploadFromStream('filename', $uploadStream);
$downloadStream = $bucket->openDownloadStream($id);
var_dump(stream_get_contents($downloadStream));
The output would then resemble::
string(6) "foobar"
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-openDownloadStreamByName.txt
View file @
f812b9e6
...
...
@@ -40,7 +40,26 @@ Errors/Exceptions
.. include:: /includes/extracts/error-gridfs-filenotfoundexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
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);
var_dump(stream_get_contents($bucket->openDownloadStreamByName('filename')));
The output would then resemble::
string(6) "foobar"
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-openUploadStream.txt
View file @
f812b9e6
...
...
@@ -40,7 +40,25 @@ 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
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$uploadStream = $bucket->openUploadStream('filename');
fwrite($uploadStream, 'foobar');
fclose($uploadStream);
$downloadStream = $bucket->openDownloadStreamByName('filename');
var_dump(stream_get_contents($downloadStream));
The output would then resemble::
string(6) "foobar"
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket-rename.txt
View file @
f812b9e6
...
...
@@ -31,4 +31,25 @@ Errors/Exceptions
.. include:: /includes/extracts/error-gridfs-filenotfoundexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$id = $bucket->uploadFromStream('a', $stream);
$bucket->rename($id, 'b');
var_dump(stream_get_contents($bucket->openDownloadStreamByName('b')));
The output would then resemble::
string(6) "foobar"
docs/reference/method/MongoDBGridFSBucket-uploadFromStream.txt
View file @
f812b9e6
...
...
@@ -43,7 +43,29 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add examples
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
$stream = fopen('php://temp', 'w+b');
fwrite($stream, "foobar");
rewind($stream);
$id = $bucket->uploadFromStream('filename', $stream);
var_dump($id);
The output would then resemble::
object(MongoDB\BSON\ObjectId)#3009 (1) {
["oid"]=>
string(24) "5acf81017e21e816e538d883"
}
See Also
--------
...
...
docs/reference/method/MongoDBGridFSBucket__construct.txt
View file @
f812b9e6
...
...
@@ -42,7 +42,25 @@ 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
Examples
--------
.. code-block:: php
<?php
$bucket = (new MongoDB\Client)->test->selectGridFSBucket();
var_dump($bucket);
The output would then resemble::
object(MongoDB\GridFS\Bucket)#3053 (2) {
["bucketName"]=>
string(4) "test"
["databaseName"]=>
string(11) "phplib_test"
}
See Also
--------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment