Skip to content

Commit a5ebba3

Browse files
committed
DOCSP-45191: MW feedback
1 parent 4faf8bb commit a5ebba3

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

source/includes/write/gridfs.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
# end-create-custom-bucket
2020

2121
# start-upload-files
22+
metadata = { uploaded_by: 'username' }
2223
File.open('/path/to/file', 'rb') do |file|
23-
file_id = bucket.upload_from_stream('test.txt', file)
24+
file_id = bucket.upload_from_stream('test.txt', file, metadata: metadata)
2425
puts "Uploaded file with ID: #{file_id}"
2526
end
2627
# end-upload-files

source/write/gridfs.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Overview
2222

2323
In this guide, you can learn how to store and retrieve large files in
2424
MongoDB by using **GridFS**. GridFS is a specification that describes how to split files
25-
into chunks when storing them and reassemble them when retrieving them. The {+driver-short+}'s
25+
into chunks when storing them and reassemble those files when retrieving them. The {+driver-short+}'s
2626
implementation of GridFS is an abstraction that manages the operations and organization of
2727
the file storage.
2828

@@ -58,8 +58,8 @@ When storing files with GridFS, the driver splits the files into smaller
5858
chunks, each represented by a separate document in the ``chunks`` collection.
5959
It also creates a document in the ``files`` collection that contains
6060
a file ID, file name, and other file metadata. You can upload the file from
61-
memory or from a stream. See the following diagram to see how GridFS splits
62-
the files when uploaded to a bucket.
61+
memory or from a stream. The following diagram shows how GridFS splits
62+
the files when they're uploaded to a bucket.
6363

6464
.. figure:: /includes/figures/GridFS-upload.png
6565
:alt: A diagram that shows how GridFS uploads a file to a bucket
@@ -75,16 +75,16 @@ Create a GridFS Bucket
7575
To store or retrieve files from GridFS, create a GridFS bucket by calling the
7676
``FSBucket.new`` method and passing in a ``Mongo::Database`` instance.
7777
You can use the ``FSBucket`` instance to
78-
call read and write operations on the files in your bucket.
78+
perform read and write operations on the files in your bucket.
7979

8080
.. literalinclude:: /includes/write/gridfs.rb
8181
:language: ruby
8282
:dedent:
8383
:start-after: start-create-bucket
8484
:end-before: end-create-bucket
8585

86-
To create or reference a bucket with a custom name other than the default name
87-
``fs``, pass the bucket name as the an optional parameter to the ``FSBucket.new``
86+
To create or reference a bucket with a name other than the default name
87+
``fs``, pass the bucket name as an optional parameter to the ``FSBucket.new``
8888
constructor, as shown in the following example:
8989

9090
.. literalinclude:: /includes/write/gridfs.rb
@@ -102,7 +102,8 @@ upload stream and saves it to the ``GridFSBucket`` instance.
102102
You can pass a ``Hash`` as an optional parameter to configure the chunk size or include
103103
additional metadata.
104104

105-
The following example uploads a file into ``FSBucket``:
105+
The following example uploads a file into ``FSBucket`` and specifies metadata for the
106+
uploaded file:
106107

107108
.. literalinclude:: /includes/write/gridfs.rb
108109
:language: ruby
@@ -119,7 +120,7 @@ about the file it refers to, including:
119120

120121
- The ``_id`` of the file
121122
- The name of the file
122-
- The length/size of the file
123+
- The size of the file
123124
- The upload date and time
124125
- A ``metadata`` document in which you can store any other information
125126

@@ -145,7 +146,7 @@ Download Files
145146
The ``download_to_stream`` method downloads the contents of a file.
146147

147148
To download a file by its file ``_id``, pass the ``_id`` to the method. The ``download_to_stream``
148-
method will write the contents of the file to the provided object.
149+
method writes the contents of the file to the provided object.
149150
The following example downloads a file by its file ``_id``:
150151

151152
.. literalinclude:: /includes/write/gridfs.rb
@@ -154,9 +155,8 @@ The following example downloads a file by its file ``_id``:
154155
:start-after: start-download-files-id
155156
:end-before: end-download-files-id
156157

157-
If you don't know the ``_id`` of the file but know the filename, then you
158-
can use the ``download_to_stream_by_name`` method. The following example
159-
downloads a file named ``mongodb-tutorial``:
158+
If you a file's name but not its ``_id``, you can use the ``download_to_stream_by_name``
159+
method. The following example downloads a file named ``mongodb-tutorial``:
160160

161161
.. literalinclude:: /includes/write/gridfs.rb
162162
:language: ruby
@@ -167,7 +167,7 @@ downloads a file named ``mongodb-tutorial``:
167167
.. note::
168168

169169
If there are multiple documents with the same ``filename`` value,
170-
GridFS will fetch the most recent file with the given name (as
170+
GridFS fetches the most recent file with the given name (as
171171
determined by the ``uploadDate`` field).
172172

173173
Delete Files
@@ -198,4 +198,4 @@ API Documentation
198198
To learn more about using GridFS to store and retrieve large files,
199199
see the following API documentation:
200200

201-
- `Mongo::Grid::FSBucket <{+api-root+}/Mongo/Grid/FSBucket.html>`_
201+
- `Mongo::Grid::FSBucket <{+api-root+}/Mongo/Grid/FSBucket.html>`__

0 commit comments

Comments
 (0)