@@ -83,7 +83,7 @@ call read and write operations on the files in your bucket.
83
83
84
84
.. literalinclude:: /includes/gridfs/gridfs.py
85
85
:language: python
86
- :copyable: true
86
+ :dedent:
87
87
:start-after: start create bucket
88
88
:end-before: end create bucket
89
89
@@ -95,7 +95,7 @@ constructor, as shown below:
95
95
96
96
.. literalinclude:: /includes/gridfs/gridfs.py
97
97
:language: python
98
- :copyable: true
98
+ :dedent:
99
99
:start-after: start create custom bucket
100
100
:end-before: end create custom bucket
101
101
@@ -104,16 +104,16 @@ constructor, as shown below:
104
104
Upload Files
105
105
------------
106
106
107
- Use the ``open_upload_stream()`` method from the ``GridFSBucket`` class to create an upload
108
- stream for a given file name. The
109
- ``open_upload_stream()`` method allows you to specify configuration information
110
- such as file chunk size and other field/value pairs to store as metadata. Set
111
- these options as parameters of ``open_upload_stream()``, as shown in the
112
- following code example:
107
+ Use the ``open_upload_stream()`` method from the ``GridFSBucket`` class to
108
+ create an upload stream for a given file name. The ``open_upload_stream()``
109
+ method allows you to specify configuration information such as file chunk
110
+ size and other field/value pairs to store as metadata. Set these options
111
+ as parameters of ``open_upload_stream()``, as shown in the following code
112
+ example:
113
113
114
114
.. literalinclude:: /includes/gridfs/gridfs.py
115
115
:language: python
116
- :copyable: true
116
+ :dedent:
117
117
:start-after: start upload files
118
118
:end-before: end upload files
119
119
@@ -138,12 +138,12 @@ from which you can access the results. To learn more about ``Cursor`` objects in
138
138
{+driver-short+}, see :ref:`<pymongo-cursors>`.
139
139
140
140
The following code example shows you how to retrieve and print file metadata
141
- from all your files in a GridFS bucket. It uses the ``for...of `` syntax to traverse the
141
+ from all your files in a GridFS bucket. It uses the ``for...in `` syntax to traverse the
142
142
``Cursor`` iterable and display the results:
143
143
144
144
.. literalinclude:: /includes/gridfs/gridfs.py
145
145
:language: python
146
- :copyable: true
146
+ :dedent:
147
147
:start-after: start retrieve file info
148
148
:end-before: end retrieve file info
149
149
@@ -162,12 +162,11 @@ You can download files from your MongoDB database by using the
162
162
download stream.
163
163
164
164
The following example shows you how to download a file referenced
165
- by the file name, stored in the ``filename`` field, into your working
166
- directory:
165
+ by the file name, ``"my_file"``, and read its contents:
167
166
168
167
.. literalinclude:: /includes/gridfs/gridfs.py
169
168
:language: python
170
- :copyable: true
169
+ :dedent:
171
170
:start-after: start download files name
172
171
:end-before: end download files name
173
172
@@ -182,7 +181,7 @@ method, which takes the ``_id`` field of a file as a parameter:
182
181
183
182
.. literalinclude:: /includes/gridfs/gridfs.py
184
183
:language: python
185
- :copyable: true
184
+ :dedent:
186
185
:start-after: start download files id
187
186
:end-before: end download files id
188
187
@@ -204,11 +203,11 @@ bucket. You must specify the file to rename by its ``_id`` field
204
203
rather than its file name.
205
204
206
205
The following example shows how to update the ``filename`` field to
207
- ``"newFileName "`` by referencing a document's ``_id`` field:
206
+ ``"new_file_name "`` by referencing a document's ``_id`` field:
208
207
209
208
.. literalinclude:: /includes/gridfs/gridfs.py
210
209
:language: python
211
- :copyable: true
210
+ :dedent:
212
211
:start-after: start rename files
213
212
:end-before: end rename files
214
213
@@ -233,7 +232,7 @@ The following example shows you how to delete a file by referencing its ``_id``
233
232
234
233
.. literalinclude:: /includes/gridfs/gridfs.py
235
234
:language: python
236
- :copyable: true
235
+ :dedent:
237
236
:start-after: start delete files
238
237
:end-before: end delete files
239
238
0 commit comments