OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, root_collection, session=None, disable_md5=False, **kwargs) |
def | abort (self) |
def | closed (self) |
def | __getattr__ (self, name) |
def | __setattr__ (self, name, value) |
def | close (self) |
def | read (self, size=-1) |
def | readable (self) |
def | seekable (self) |
def | write (self, data) |
def | writelines (self, sequence) |
def | writeable (self) |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_val, exc_tb) |
Static Public Attributes | |
read_only | |
filename | |
name | |
content_type | |
length | |
closed_only | |
chunk_size | |
upload_date | |
md5 | |
Class to write data to GridFS.
def __init__ | ( | self, | |
root_collection, | |||
session = None , |
|||
disable_md5 = False , |
|||
** | kwargs | ||
) |
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.collection.Collection`. Any of the file level options specified in the `GridFS Spec <http://dochub.mongodb.org/core/gridfsspec>`_ may be passed as keyword arguments. Any additional keyword arguments will be set as additional fields on the file document. Valid keyword arguments include: - ``"_id"``: unique ID for this file (default: :class:`~bson.objectid.ObjectId`) - this ``"_id"`` must not have already been used for another file - ``"filename"``: human name for the file - ``"contentType"`` or ``"content_type"``: valid mime-type for the file - ``"chunkSize"`` or ``"chunk_size"``: size of each of the chunks, in bytes (default: 255 kb) - ``"encoding"``: encoding used for this file. In Python 2, any :class:`unicode` that is written to the file will be converted to a :class:`str`. In Python 3, any :class:`str` that is written to the file will be converted to :class:`bytes`. :Parameters: - `root_collection`: root collection to write to - `session` (optional): a :class:`~pymongo.client_session.ClientSession` to use for all commands - `disable_md5` (optional): When True, an MD5 checksum will not be computed for the uploaded file. Useful in environments where MD5 cannot be used for regulatory or other reasons. Defaults to False. - `**kwargs` (optional): file level options (see above) .. versionchanged:: 3.6 Added ``session`` parameter. .. versionchanged:: 3.0 `root_collection` must use an acknowledged :attr:`~pymongo.collection.Collection.write_concern`
def __enter__ | ( | self | ) |
Support for the context manager protocol.
def __exit__ | ( | self, | |
exc_type, | |||
exc_val, | |||
exc_tb | |||
) |
Support for the context manager protocol. Close the file and allow exceptions to propagate.
def __getattr__ | ( | self, | |
name | |||
) |
def __setattr__ | ( | self, | |
name, | |||
value | |||
) |
def abort | ( | self | ) |
Remove all chunks/files that may have been uploaded and close.
def close | ( | self | ) |
Flush the file and close it. A closed file cannot be written any more. Calling :meth:`close` more than once is allowed.
def closed | ( | self | ) |
Is this file closed?
def read | ( | self, | |
size = -1 |
|||
) |
def readable | ( | self | ) |
def seekable | ( | self | ) |
def write | ( | self, | |
data | |||
) |
Write data to the file. There is no return value. `data` can be either a string of bytes or a file-like object (implementing :meth:`read`). If the file has an :attr:`encoding` attribute, `data` can also be a :class:`unicode` (:class:`str` in python 3) instance, which will be encoded as :attr:`encoding` before being written. Due to buffering, the data may not actually be written to the database until the :meth:`close` method is called. Raises :class:`ValueError` if this file is already closed. Raises :class:`TypeError` if `data` is not an instance of :class:`str` (:class:`bytes` in python 3), a file-like object, or an instance of :class:`unicode` (:class:`str` in python 3). Unicode data is only allowed if the file has an :attr:`encoding` attribute. :Parameters: - `data`: string of bytes or file-like object to be written to the file
def writeable | ( | self | ) |
def writelines | ( | self, | |
sequence | |||
) |
Write a sequence of strings to the file. Does not add seperators.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |