MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / __init__

Method __init__

gridfs/synchronous/grid_file.py:1078–1164  ·  view source on GitHub ↗

Write a file to GridFS Application developers should generally not need to instantiate this class directly - instead see the methods provided by :class:`~gridfs.GridFS`. Raises :class:`TypeError` if `root_collection` is not an instance of :class:`~pymongo.co

(
        self,
        root_collection: Collection[Any],
        session: Optional[ClientSession] = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

ConfigurationErrorClass · 0.90
ObjectIdClass · 0.90
_disallow_transactionsFunction · 0.70
popMethod · 0.45
getMethod · 0.45
__setattr__Method · 0.45

Tested by

no test coverage detected