File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 10
10
11
11
# start upload files
12
12
with bucket .open_upload_stream (
13
- "my_file" , chunk_size_bytes = 4 ,
13
+ "my_file" , chunk_size_bytes = 1048576 ,
14
14
metadata = {"contentType" : "text/plain" }) as grid_in :
15
15
grid_in .write ("data to store" )
16
16
# end upload files
Original file line number Diff line number Diff line change @@ -104,15 +104,12 @@ constructor, as shown below:
104
104
Upload Files
105
105
------------
106
106
107
- Use the ``open_upload_stream()`` method from the ``GridFSBucket`` class to upload
108
- a file to a GridFS bucket. Pass the following parameters to the ``open_upload_stream()``
109
- method:
110
-
111
- - ``filename``: The name of the file you want to upload
112
- - ``chunk_size_bytes``: The number of bytes per chunk of this file (optional)
113
- - ``metadata``: The file metadata (optional)
114
-
115
- The following code example uploads a file named ``"my_file"`` to a GridFS bucket:
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:
116
113
117
114
.. literalinclude:: /includes/gridfs/gridfs.py
118
115
:language: python
@@ -161,8 +158,8 @@ Download Files
161
158
--------------
162
159
163
160
You can download files from your MongoDB database by using the
164
- ``open_download_stream_by_name()`` method from the ``GridFSBucket``
165
- class .
161
+ ``open_download_stream_by_name()`` method from ``GridFSBucket`` to create a
162
+ download stream .
166
163
167
164
The following example shows you how to download a file referenced
168
165
by the file name, ``"my_file"``, and read its contents:
You can’t perform that action at this time.
0 commit comments