@@ -18,9 +18,9 @@ Overview
18
18
In this guide, you can learn how to store and retrieve large files in
19
19
MongoDB using the **GridFS** specification. GridFS splits large files
20
20
into chunks and stores each chunk as a separate document. When you query
21
- GridFS for a file, the driver will reassemble the chunks as needed. The
21
+ GridFS for a file, the driver assembles the chunks as needed. The
22
22
driver implementation of GridFS is an abstraction that manages the operations
23
- and organization of the file storage.
23
+ and organization of the file storage.
24
24
25
25
Use GridFS if the size of your files exceeds the BSON document size limit of
26
26
16 MB. GridFS is also useful for accessing files without loading the entire file
@@ -37,7 +37,7 @@ bucket contains the following collections:
37
37
- The ``chunks`` collection, which stores the binary file chunks.
38
38
- The ``files`` collection, which stores the file metadata.
39
39
40
- When you create a new GridFS bucket, the driver creates the preceding
40
+ When you create a new GridFS bucket, the driver creates the preceding
41
41
collections. The default bucket name ``fs`` prefixes the collection names,
42
42
unless you specify a different bucket name. The driver creates the new GridFS
43
43
bucket during the first write operation.
@@ -98,15 +98,15 @@ call the ``NewBucket()`` method with a database parameter:
98
98
reference to the bucket rather than instantiating a new one.
99
99
100
100
By default, the new bucket is named ``fs``. To instantiate a bucket with a
101
- custom name, call the ``SetName()`` method on a ``BucketOptions`` instance as
101
+ custom name, call the ``SetName()`` method on a ``BucketOptions`` instance as
102
102
follows:
103
103
104
104
.. code-block:: go
105
105
106
106
db := client.Database("myDB")
107
107
opts := options.GridFSBucket().SetName("custom name")
108
108
bucket, err := gridfs.NewBucket(db, opts)
109
-
109
+
110
110
if err != nil {
111
111
panic(err)
112
112
}
@@ -122,7 +122,7 @@ You can upload a file into a GridFS bucket in one of the following ways:
122
122
- Use the ``OpenUploadStream()`` method, which writes to an output stream.
123
123
124
124
For either upload process, you can specify configuration information on an instance
125
- of ``UploadOptions``. For a full list of ``UploadOptions`` fields, visit the
125
+ of ``UploadOptions``. For a full list of ``UploadOptions`` fields, visit the
126
126
`API documentation <{+api+}/mongo/options#UploadOptions>`__.
127
127
128
128
Upload with an Input Stream
@@ -159,12 +159,8 @@ content to a GridFS bucket. It uses an ``opts`` parameter to set file metadata:
159
159
:language: none
160
160
:visible: false
161
161
162
- New file uploaded with ID 62e005408bc04f3816b8bcd2
163
-
164
- .. note::
162
+ New file uploaded with ID 62e00...
165
163
166
- The driver uniquely generates each object ID number. The ID number outputted
167
- will resemble the sample output but varies with each file and user.
168
164
169
165
Upload with an Output Stream
170
166
````````````````````````````
@@ -208,7 +204,7 @@ only certain file documents.
208
204
209
205
.. note::
210
206
211
- The ``Find()`` method requires a query filter as a parameter. To match all
207
+ The ``Find()`` method requires a query filter as a parameter. To match all
212
208
documents in the ``files`` collection, pass an empty query filter to ``Find()``.
213
209
214
210
The following example retrieves the file name and length of documents in the
@@ -292,7 +288,7 @@ Rename Files
292
288
293
289
You can update the name of a GridFS file in your bucket by using the ``Rename()``
294
290
method. Pass a file ID value and a new ``filename`` value as arguments to
295
- ``Rename()``.
291
+ ``Rename()``.
296
292
297
293
The following example renames a file to ``"mongodbTutorial.zip"``:
298
294
@@ -309,7 +305,7 @@ Delete Files
309
305
~~~~~~~~~~~~
310
306
311
307
You can remove a file from your GridFS bucket by using the ``Delete()`` method.
312
- Pass a file ID value as an argument to ``Delete()``.
308
+ Pass a file ID value as an argument to ``Delete()``.
313
309
314
310
The following example deletes a file:
315
311
0 commit comments