Skip to content

Commit 34a6abf

Browse files
committed
JM feedback 2
1 parent 6d401a0 commit 34a6abf

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

source/includes/write/gridfs.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,8 @@ function toJSON(object $document): string
3939

4040
// Uploads data to a stream, then writes the stream to a GridFS file
4141
// start-upload-from-stream
42-
$stream = fopen('php://temp', 'w+b');
43-
fwrite($stream, 'Data to store');
44-
rewind($stream);
45-
46-
$bucket->uploadFromStream('new_file', $stream);
42+
$file = fopen('/path/to/file', 'rb');
43+
$bucket->uploadFromStream('new_file', $file);
4744
// end-upload-from-stream
4845

4946
// Prints information about each file in the bucket
@@ -78,10 +75,10 @@ function toJSON(object $document): string
7875

7976
// Downloads an entire GridFS file to a download stream
8077
// start-download-to-stream
81-
$stream = fopen('php://temp', 'w+b');
78+
$stream = fopen('/path/to/output-file', 'wb');
8279
$bucket->downloadToStream(
8380
new ObjectID('66e0a5487c880f844c0a32b1'),
84-
$stream
81+
$stream,
8582
);
8683
// end-download-to-stream
8784

source/write/gridfs.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ information in an options array, which you can pass as a parameter.
183183

184184
This example performs the following actions:
185185

186-
- Calls the ``fopen()`` method to create a temporary memory-based stream
187-
that you can write to and read from
188-
- Calls the ``fwrite()`` method to write data to the stream
186+
- Calls the ``fopen()`` method to open a file located at ``/path/to/file``
187+
as a stream in binary read (``rb``) mode
189188
- Calls the ``uploadFromStream()`` method to upload the contents of the stream
190189
to a GridFS file named ``'new_file'``
191190

@@ -320,7 +319,9 @@ method, which takes the ``_id`` field of a file as a parameter:
320319
stream needs to pull a chunk from MongoDB, it pulls the entire chunk
321320
into memory. The 255-kilobyte default chunk size is usually
322321
sufficient, but you can reduce the chunk size to reduce memory
323-
overhead.
322+
overhead or increase the chunk size when working with larger files.
323+
For more information about setting the chunk size, see the
324+
:ref:`gridfs-create-custom-bucket` section of this page.
324325

325326
Download a File Revision
326327
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -355,8 +356,9 @@ on your bucket.
355356

356357
This example performs the following actions:
357358

358-
- Calls the ``fopen()`` method to open a download stream
359-
- Downloads a file that has an ``_id`` value of ``ObjectID('66e0a5487c880f844c0a32b1')``
359+
- Calls the ``fopen()`` method to open a file located at ``/path/to/output-file``
360+
as a stream in binary write (``wb``) mode
361+
- Downloads a GridFS file that has an ``_id`` value of ``ObjectID('66e0a5487c880f844c0a32b1')``
360362
to the stream
361363

362364
.. literalinclude:: /includes/write/gridfs.php

0 commit comments

Comments
 (0)