![]() |
Coretex
|
Public Member Functions | |
Self | createFromPath (cls, str parameterName, Union[Path, str] filePath, Optional[str] fileName=None, Optional[str] mimeType=None) |
Self | createFromBytes (cls, str parameterName, bytes fileBytes, str fileName, Optional[str] mimeType=None) |
Tuple[str, Tuple[str, Union[bytes, BinaryIO], str]] | prepareForUpload (self, ExitStack exitStack) |
Class which describes file which will be uploaded using NetworkManager.genericUpload function. To upload a file either its "filePath" or "fileBytes" must be set, otherwise it will raise an exception. "filePath" will upload the file from the specified path, while "fileBytes" will upload the file directly from the memory. If both parameters have value "fileBytes" will be used. Objects of this class should not be instantiated directly, use either "FileData.createFromPath" or "FileData.createFromBytes" to instantiate the object. Properties ---------- parameterName : str Name of the form-data parameter fileName : str Name of the file which will be uploaded mimeType : str Mime type of the file which will be uploaded filePath : Optional[str] Path to the file which will be uploaded fileBytes : Optional[bytes] Bytes of the file which will be uploaded
Definition at line 26 of file file_data.py.
Self coretex.networking.file_data.FileData.createFromBytes | ( | cls, | |
str | parameterName, | ||
bytes | fileBytes, | ||
str | fileName, | ||
Optional[str] | mimeType = None |
||
) |
Creates "FileData" object from the provided bytes. Use this function if you want to upload a file directly from memory. Parameters ---------- parameterName : str Name of the form-data parameter fileBytes : bytes Bytes of the file which will be uploaded fileName : str Name of the file which will be uploaded, if None it will be extracted from the "filePath" parameter mimeType : Optional[str] Mime type of the file which will be uploaded, if None it will be set to "application/octet-stream". Returns ------- Self -> on object which describes how a path should be uploaded from memory
Definition at line 124 of file file_data.py.
Self coretex.networking.file_data.FileData.createFromPath | ( | cls, | |
str | parameterName, | ||
Union[Path, str] | filePath, | ||
Optional[str] | fileName = None , |
||
Optional[str] | mimeType = None |
||
) |
Creates "FileData" object from the specified file path. Use this function if you want to upload a file directly from path. Parameters ---------- parameterName : str Name of the form-data parameter filePath : Union[Path, str] Path to the file which will be uploaded fileName : Optional[str] Name of the file which will be uploaded, if None it will be extracted from the "filePath" parameter mimeType : Optional[str] Mime type of the file which will be uploaded, if None it will be guessed. If it is not possible to guess an exception will be raised. In that case provide the mime type manually. Returns ------- Self -> on object which describes how a path should be uploaded from path Raises ------ ValueError -> if "filePath" is not a valid file
Definition at line 74 of file file_data.py.
Tuple[str, Tuple[str, Union[bytes, BinaryIO], str]] coretex.networking.file_data.FileData.prepareForUpload | ( | self, | |
ExitStack | exitStack | ||
) |
Converts the "FileData" object into a format which can be used by the requests library for uploading files. Parameters ---------- exitStack : ExitStack Context stack which contains the context of files opened by the "FileData" object. Used to join multiple file contexts, so if one raises an exception all the files will properly get closed. Returns ------- Tuple[str, Tuple[str, Any, str]] -> Format accepted by the requests library for uploading files.
Definition at line 168 of file file_data.py.