@@ -22,7 +22,7 @@ Overview
2222
2323In this guide, you can learn how to store and retrieve large files in
2424MongoDB 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
2626implementation of GridFS is an abstraction that manages the operations and organization of
2727the file storage.
2828
@@ -58,8 +58,8 @@ When storing files with GridFS, the driver splits the files into smaller
5858chunks, each represented by a separate document in the ``chunks`` collection.
5959It also creates a document in the ``files`` collection that contains
6060a 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
7575To store or retrieve files from GridFS, create a GridFS bucket by calling the
7676``FSBucket.new`` method and passing in a ``Mongo::Database`` instance.
7777You 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``
8888constructor, 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.
102102You can pass a ``Hash`` as an optional parameter to configure the chunk size or include
103103additional 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
145146The ``download_to_stream`` method downloads the contents of a file.
146147
147148To 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.
149150The 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
173173Delete Files
@@ -198,4 +198,4 @@ API Documentation
198198To learn more about using GridFS to store and retrieve large files,
199199see 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