MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / AsyncGridIn

Class AsyncGridIn

gridfs/asynchronous/grid_file.py:1083–1447  ·  view source on GitHub ↗

Class to write data to GridFS.

Source from the content-addressed store, hash-verified

1081
1082
1083class AsyncGridIn:
1084 """Class to write data to GridFS."""
1085
1086 def __init__(
1087 self,
1088 root_collection: AsyncCollection[Any],
1089 session: Optional[AsyncClientSession] = None,
1090 **kwargs: Any,
1091 ) -> None:
1092 """Write a file to GridFS
1093
1094 Application developers should generally not need to
1095 instantiate this class directly - instead see the methods
1096 provided by :class:`~gridfs.GridFS`.
1097
1098 Raises :class:`TypeError` if `root_collection` is not an
1099 instance of :class:`~pymongo.collection.AsyncCollection`.
1100
1101 Any of the file level options specified in the `GridFS Spec
1102 <http://dochub.mongodb.org/core/gridfsspec>`_ may be passed as
1103 keyword arguments. Any additional keyword arguments will be
1104 set as additional fields on the file document. Valid keyword
1105 arguments include:
1106
1107 - ``"_id"``: unique ID for this file (default:
1108 :class:`~bson.objectid.ObjectId`) - this ``"_id"`` must
1109 not have already been used for another file
1110
1111 - ``"filename"``: human name for the file
1112
1113 - ``"contentType"`` or ``"content_type"``: valid mime-type
1114 for the file
1115
1116 - ``"chunkSize"`` or ``"chunk_size"``: size of each of the
1117 chunks, in bytes (default: 255 kb)
1118
1119 - ``"encoding"``: encoding used for this file. Any :class:`str`
1120 that is written to the file will be converted to :class:`bytes`.
1121
1122 :param root_collection: root collection to write to
1123 :param session: a
1124 :class:`~pymongo.client_session.AsyncClientSession` to use for all
1125 commands
1126 :param kwargs: Any: file level options (see above)
1127
1128 .. versionchanged:: 4.0
1129 Removed the `disable_md5` parameter. See
1130 :ref:`removed-gridfs-checksum` for details.
1131
1132 .. versionchanged:: 3.7
1133 Added the `disable_md5` parameter.
1134
1135 .. versionchanged:: 3.6
1136 Added ``session`` parameter.
1137
1138 .. versionchanged:: 3.0
1139 `root_collection` must use an acknowledged
1140 :attr:`~pymongo.collection.AsyncCollection.write_concern`

Callers 15

test_basicMethod · 0.90
test_md5Method · 0.90
test_write_file_likeMethod · 0.90
test_write_linesMethod · 0.90
test_closeMethod · 0.90
test_closedMethod · 0.90

Calls 1

_a_grid_in_propertyFunction · 0.90

Tested by 15

test_basicMethod · 0.72
test_md5Method · 0.72
test_write_file_likeMethod · 0.72
test_write_linesMethod · 0.72
test_closeMethod · 0.72
test_closedMethod · 0.72