cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mathewreed
Community Participant

File URL's

Jump to solution

I'm wanting to know how to find the URL of the files within a course. 

The purpose is to upload a video/image into a course. From there, if we then wanted to Iframe the image or video into the course, what is the URL that I would place into the iframe html code?

Thanks!

1 Solution

Accepted Solutions
canvas18
Community Participant

Mat,

Finding a direct URL isn't difficult, but you need to build it by hand.

Here is what Canvas returns:

https://canvas.instructure.com/files/52670401/download?verifier=R0L5VHPb6vGHZc2C4XENYH3N0iZ87JzvPTPB... 

Not useful for direct linking.  Instead, you need this...

https://canvas.instructure.com/courses/1177058/file_contents/course%20files/lesson_1/900XLSN1/index.... 

To get the URL:

1) Get the course root URL from your browser address bar --> https://canvas.instructure.com/courses/1177058/

2) Add in the URL for the file system -->  file_contents/course%20files/ 

3) Add the URL to the actual file location in the file system --> lesson_1/900XLSN1/index.html

You can get the url for the file (part 3) from the files area.  If you have spaces in the file name, make sure you replace them with %20.

If  @James  would build a Canvancement ( Canvancements - Canvas Enhancements‌ ) for this, it would be great.

View solution in original post

6 Replies
canvas18
Community Participant

Mat,

Finding a direct URL isn't difficult, but you need to build it by hand.

Here is what Canvas returns:

https://canvas.instructure.com/files/52670401/download?verifier=R0L5VHPb6vGHZc2C4XENYH3N0iZ87JzvPTPB... 

Not useful for direct linking.  Instead, you need this...

https://canvas.instructure.com/courses/1177058/file_contents/course%20files/lesson_1/900XLSN1/index.... 

To get the URL:

1) Get the course root URL from your browser address bar --> https://canvas.instructure.com/courses/1177058/

2) Add in the URL for the file system -->  file_contents/course%20files/ 

3) Add the URL to the actual file location in the file system --> lesson_1/900XLSN1/index.html

You can get the url for the file (part 3) from the files area.  If you have spaces in the file name, make sure you replace them with %20.

If  @James  would build a Canvancement ( Canvancements - Canvas Enhancements‌ ) for this, it would be great.

View solution in original post

laurakgibbs
Community Champion

Thanks for that  @canvas18 ‌! I didn't know about that technique using the file name!

Depending on the ultimate use of the file reference, you can also use this numbers-only approach, which does work for iframes.

Start with the URL you see when you preview the file. For example:

https://canvas.ou.edu/courses/56095/files?preview=5800122

The bolded bits go into the iframe like this:

<iframe style="display: block; margin-left: auto; margin-right: auto;" src="https://canvas.ou.edu/courses/56095/files/5800122/download" width="500" height="1200"></iframe>

For an example, here are instructions for uploading a Twitter widget javascript as a file and then iframing that into a Page where I used that File and that iframe:

An #InstCon Twitter Widget in Under 5 Minutes 

Here is the page with that iframe code:

It's #InstCon at Twitter: Twitter4Canvas 

James
Community Champion

 @canvas18  

I don't see a Canvancement coming out of this, although it seems to tie into the request for an embed an iframe feature request that is on Product Radar.

Portions of step 1 should be unnecessary and you could use a relative url instead of an absolute one. That is, omit the protocol and hostname and just use  /courses/1177058/file_contents/course%20files/FOLDER/FILENAME

tpha
Community Participant

Mike, patching together an URL by hand seems tedious and something from the past 🙂 It would be great if you add a possibility to copy a direct URL to individual  files and folders in Canvas file system - as is possible in Google drive, Onedrive, Dropbox etc. I certainly need that in communication and planning in the teachers team... Thanks in advance, Thure

canvas18
Community Participant

Thure,

Concur.  Unfortunately, I'm not a programmer and I don't own the system I'm working on (open source Canvas).

Hopefully somebody from Canvas will see this and consider it for a future update.

rebyers
Community Participant

This did not work for me despite carefully following the instructions.  However, my instructional designer suggested just right clicking the file's link in the Files section of Canvas and using the "copy link address" to get the URL for downloading that file.  I used that and it worked beautifully.