Skip to content

Commit e1f1190

Browse files
committed
JM last feedback
1 parent af8020c commit e1f1190

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

source/includes/write/gridfs.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<?php
2-
require 'vendor/autoload.php'; // include Composer's autoloader
2+
require 'vendor/autoload.php';
33

44
use MongoDB\Client;
5-
use MongoDB\BSON\ObjectID;
6-
use MongoDB\GridFS\Bucket;
7-
use MongoDB\Driver\Manager;
5+
use MongoDB\BSON\ObjectId;
86

97
$uri = getenv('MONGODB_URI') ?: throw new RuntimeException('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset');
10-
$client = new MongoDB\Client($uri);
8+
$client = new Client($uri);
119

1210
// start-to-json
1311
function toJSON(object $document): string
@@ -59,9 +57,9 @@ function toJSON(object $document): string
5957
fclose($stream);
6058
// end-open-download-stream-name
6159

62-
// Downloads a file from the GridFS bucket by referencing its ObjectID value
60+
// Downloads a file from the GridFS bucket by referencing its ObjectId value
6361
// start-download-files-id
64-
$stream = $bucket->openDownloadStream(new ObjectID('66e0a5487c880f844c0a32b1'));
62+
$stream = $bucket->openDownloadStream(new ObjectId('66e0a5487c880f844c0a32b1'));
6563
$contents = stream_get_contents($stream);
6664
fclose($stream);
6765
// end-download-files-id
@@ -75,19 +73,19 @@ function toJSON(object $document): string
7573

7674
// Downloads an entire GridFS file to a download stream
7775
// start-download-to-stream
78-
$stream = fopen('/path/to/output_file', 'wb');
76+
$file = fopen('/path/to/output_file', 'wb');
7977
$bucket->downloadToStream(
80-
new ObjectID('66e0a5487c880f844c0a32b1'),
81-
$stream,
78+
new ObjectId('66e0a5487c880f844c0a32b1'),
79+
$file,
8280
);
8381
// end-download-to-stream
8482

85-
// Renames a file from the GridFS bucket with the specified ObjectID
83+
// Renames a file from the GridFS bucket with the specified ObjectId
8684
// start-rename-files
87-
$bucket->rename(new ObjectID('66e0a5487c880f844c0a32b1'), 'new_file_name');
85+
$bucket->rename(new ObjectId('66e0a5487c880f844c0a32b1'), 'new_file_name');
8886
// end-rename-files
8987

90-
// Deletes a file from the GridFS bucket with the specified ObjectID
88+
// Deletes a file from the GridFS bucket with the specified ObjectId
9189
// start-delete-files
92-
$bucket->delete(new ObjectID('66e0a5487c880f844c0a32b1'));
90+
$bucket->delete(new ObjectId('66e0a5487c880f844c0a32b1'));
9391
// end-delete-files

source/write/gridfs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ This example performs the following actions:
360360

361361
- Calls the ``fopen()`` method to open a file located at ``/path/to/output_file``
362362
as a stream in binary write (``wb``) mode
363-
- Downloads a GridFS file that has an ``_id`` value of ``ObjectID('66e0a5487c880f844c0a32b1')``
363+
- Downloads a GridFS file that has an ``_id`` value of ``ObjectId('66e0a5487c880f844c0a32b1')``
364364
to the stream
365365

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

0 commit comments

Comments
 (0)