Skip to contents

Uploads an image file to Canvas using the file upload API documented at https://canvas.instructure.com/doc/api/file.file_uploads.html.

Usage

canvas_upload_image(name, parent_folder_path = NULL)

Arguments

name

Path to image on local system (can be relative to the current working directory).

parent_folder_path

Path of parent folder in the Canvas course where the file will be uploaded (relative to the course root folder). This only affects where you could find it using Canvas' image selector; the URL to the image always follows the flat structure shown in Examples.

Value

URL to image preview within Canvas course, suitable as the source attribute for an image html tag. attr(result, "id") will return the id of the created file.

Examples

if (FALSE) { # \dontrun{
# Returns something like "https://example.instructure.com/courses/1234/files/5678/preview"
name <- tempfile(fileext = ".png")
png(name)
plot(1:10)
dev.off()
canvas_upload_image(name, "subfolder")
} # }