Skip to content

Commit 3b9ce40

Browse files
committed
JT feedback 2
1 parent b1e5293 commit 3b9ce40

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

source/includes/usage-examples/write-code-examples.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@
108108
// end-bulk-write
109109

110110
// Creates a GridFS bucket or references an existing one
111-
// start-gridfs
111+
// start-gridfs-bucket
112112
$bucket = $client->selectDatabase('<database name>')->selectGridFSBucket();
113-
// end-gridfs
113+
// end-gridfs-bucket
114+
115+
// Stores a file in a GridFS bucket and writes data to the file
116+
// start-gridfs-upload
117+
$stream = $bucket->openUploadStream('<file name>');
118+
fwrite($stream, '<data>');
119+
fclose($stream);
120+
// end-gridfs-upload

source/write.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,32 @@ operation:
171171
To learn more about the ``MongoDB\Collection::bulkWrite()`` method, see the
172172
:ref:`Bulk Write <php-bulk-write>` guide.
173173

174-
Store Large Files
175-
-----------------
174+
Create a GridFS Bucket
175+
----------------------
176176

177177
The following code shows how to create or reference a GridFS bucket, which
178178
you can write large files to:
179179

180180
.. literalinclude:: /includes/usage-examples/write-code-examples.php
181-
:start-after: start-gridfs
182-
:end-before: end-gridfs
181+
:start-after: start-gridfs-bucket
182+
:end-before: end-gridfs-bucket
183183
:language: php
184184
:dedent:
185185

186186
To learn more about the ``MongoDB\Database::selectGridFSBucket()`` method, see the
187187
:ref:`Store Large Files <php-gridfs>` guide.
188+
189+
Store GridFS Files
190+
------------------
191+
192+
The following code shows how to store files in a GridFS bucket by
193+
creating an upload stream:
194+
195+
.. literalinclude:: /includes/usage-examples/write-code-examples.php
196+
:start-after: start-gridfs-upload
197+
:end-before: end-gridfs-upload
198+
:language: php
199+
:dedent:
200+
201+
To learn more about the ``MongoDB\GridFS\Bucket::openUploadStream()`` method, see the
202+
:ref:`Store Large Files <php-gridfs>` guide.

0 commit comments

Comments
 (0)