Folder

class canvasapi.folder.Folder(requester, attributes)
Parameters:
  • requester (canvasapi.requester.Requester) – The requester to pass HTTP requests through.

  • attributes (dict) – The JSON object to build this object with.

copy_file(source_file, **kwargs)

Copies a file into the current folder.

Calls:

POST /api/v1/folders/:dest_folder_id/copy_file

Parameters:

source_file (int or canvasapi.file.File) – The object or id of the source file.

Return type:

canvasapi.folder.Folder

create_folder(name, **kwargs)

Creates a folder within this folder.

Calls:

POST /api/v1/folders/:folder_id/folders

Parameters:

name (str) – The name of the folder.

Return type:

canvasapi.folder.Folder

delete(**kwargs)
Remove this folder. You can only delete empty folders unless you set the

‘force’ flag.

Calls:

DELETE /api/v1/folders/:id

Return type:

canvasapi.folder.Folder

get_files(**kwargs)

Returns the paginated list of files for the folder.

Calls:

GET /api/v1/folders/:id/files

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.file.File

get_folders(**kwargs)

Returns the paginated list of folders in the folder.

Calls:

GET /api/v1/folders/:id/folders

Return type:

canvasapi.paginated_list.PaginatedList of canvasapi.folder.Folder

update(**kwargs)

Updates a folder.

Calls:

PUT /api/v1/folders/:id

Return type:

canvasapi.folder.Folder

upload(file: PathLike | str | IOBase | FileIO, **kwargs)

Upload a file to this folder.

Calls:

POST /api/v1/folders/:folder_id/files

Parameters:

file (file or str) – The file or path of the file to upload.

Returns:

True if the file uploaded successfully, False otherwise, and the JSON response from the API.

Return type:

tuple