Canvas file retrieval

One of the big disappointments in Canvas is the file storage system. It is easy to add files to a Canvas course, and it is easy to put file contents into a module, or add an image to a wiki page from the files. However, if you have content other than an image or html, there is no straightforward way to embed that file into a wiki page. This is of course a huge problem for me when it comes to Flash content. I want to embed flash into my pages and quiz questions, and they need to come from a secure location. The obvious secure location for most faculty is inside their Canvas course. Unfortunately, grabbing the address of the file is annoyingly complex. Trying to grab the link that appears in a wiki page or Files listing doesn’t work. Today I learned the solution.

/courses/:course_id/file_contents/course%20files/[path to file with display name as shown]

Here is an example, which I’m using for testing. I’ve uploaded a video file named alt-f9.mp4. It is in a course with an id of 30199 at the university of Delaware. Please note that this course is open to the public, so access to the files is not restricted by roster. I don’t recall doing anything to open permissions on the file itself, but in a protected course, you would want to make sure to make any file you need to access from outside of Canvas as open as possible.

So, the full url of the video, following the pattern above is

https://udel.instructure.com/courses/301991/file_contents/course%20files/alt-f9.mp4.

When I navigate directly to that page here in my Chrome Bit browser, I get an offer to download it, which is not terribly useful. But it seems to work okay inside a video tag.

So here is the video tag I’m going to insert into the html of this post:

<video src=”https://udel.instructure.com/courses/301991/file_contents/course%20files/alt-f9.mp4″ width=”640″ height=”480″ controls></video>

Here goes.

I still don’t have an easy way to generate that link. I could wish that Canvas, like Sakai, gave every user a documented way to get the link. However, the fact that I have a way is a huge relief, and I wanted to get the secret into my blog so I can find it again when I need it.

There are other issues with the Canvas file system, which I may try to code around with an External Tool. I need to generate a list of all the things people might want to do and currently can’t. For people who want to use Files the way they currently use Resources in Sakai, it’s a long list, and I probably wouldn’t want to recreate all of it, but at a minimum they might want a way to control the order files appear in, and access the proper link addresses. Generating embed code for selected file types would be something to consider as well.

 

Leave a Reply