Uploader¶
-
class
canvasapi.upload.
Uploader
(requester, url, file: Union[os.PathLike, str, io.IOBase, _io.FileIO], **kwargs)¶ Upload a file to Canvas.
Parameters: - requester (
canvasapi.requester.Requester
) – Thecanvasapi.requester.Requester
to pass requests through. - url (str) – The URL to upload the file to.
- file (
os.PathLike
or str) – A file handler or path of the file to upload.
-
request_upload_token
(file)¶ Request an upload token.
Parameters: file – A file handler pointing to the file to upload. Returns: True if the file uploaded successfully, False otherwise, and the JSON response from the API. Return type: tuple
-
start
()¶ Kick off uploading process. Handles open/closing file if a path is passed.
Calls: request_upload_token Returns: True if the file uploaded successfully, False otherwise, and the JSON response from the API. Return type: tuple
-
upload
(response, file)¶ Upload the file.
Parameters: - response (dict) – The response from the upload request.
- file – A file handler pointing to the file to upload.
Returns: True if the file uploaded successfully, False otherwise, and the JSON response from the API.
Return type: tuple
- requester (