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

Permalinks to Files?

Is there any way to get a permalink to a file in the Files section in a Course? If there is, I can't find it. When any file is updated, it gets a new reference URL which destroys the ability to link to the file and update it in the future without going back are resetting all the links you've made to the file. In other words, if I upload a .zip file to Files, a link to it looks something like this: , but if a overwrite the file with a newer version, the preview=804245 part of the link is now preview=804346 or some other number. 

This flies in the face of good database-driven CMS/LMS design. Anything stored in the database should have a way of getting a permanent link so the updating links issue doesn't present itself. Also, there's an actual Paradox in this non-permalink issue. I have html pages in my files that should cross-link each other, but if I update one page with the link to the other page, then that page has a new preview number, so the second page linked back to the first fails to link to it. And if I update that page with the correct link to the first one, the first one now has a bad link to the second. That's why you don't design a system that doesn't have permalinks.

 permalink , permalinks

19 Replies
Community Champion

EEGAD: I did not know about this. Thank you so much for pointing that out! OUCH.

I've been advocating that people use the Files space to upload javascript calls (like for Flickr slideshows, Pinterest widgets, Twitter widgets, or your own javascript widgets)... but I did not realize that Files got a new name when they were updated.

That is seriously terrible, and I agree with you that it flies in the face of good design practice. 

It's very frustrating to me that the Files section doesn't work like real webspace in your own directly (so that you can directly link to things via a simple URL, instead of the https://___/courses/___/files/___/download ), but I had no idea that when you overwrote a file with a new version that the file number actually changed.

That is what I think you are saying here, and I am going to go test that for myself to make sure I understand.

Pinging  @James ‌ ... although I know he is on the road (with CanvasKids!) so he probably won't see this right away.

Community Champion

Whoa whoa whoa whoa: you are right,  @jkhazar253 , and I agree that this is a HUGE problem. It also flies in the face of what Canvas is telling users, so I never even suspected that something this wrong was happening.

The prompt tells me that I am REPLACING the File, and I say yes, please, replace the file:

replace file screenshot

But it is not replacing the file, just as you have pointed out. 

The first file got this number:

update: that link is now broken as a result of my having "replaced" the file with a new version

But then the file with the same name, the file that I (supposedly) replaced with a new file is actually a new file with a new number: 

Words fail me for how terrible this is. Now I feel like I should not encourage people to use Files in this way because they cannot update the content safely. I really thought using Files this way to help people use dynamic scripts was a really good solution. But now I realize it is not a solution at all. If you want to work with content in this way (calling the contents of a file to run as a script in an iframe, for example), you really need your own webspace.

So... thank you so much for pointing this out! I (wrongly) assumed that when Canvas told me I was replacing the existing file that I was doing exactly that: replacing the file. I had no idea that Canvas was creating a new file with a new number. And now I have to figure out what to do. I feel terrible now for advocating to people that they use the Files space. It looks like anyone who is serious about content and asset management has got to use their own webspace instead. Otherwise, Canvas is basically telling you that you can never change your content; you are stuck with the old version OR you are going to break your own calls to the FIle.

Well, I always use my own webspace anyway... so I will just say once again, THREE CHEERS for the great guys at Reclaim Hosting and their incredibly easy HTTPS option:

Reclaim Hosting | Take Control of your Digital Identity 

Can anybody from Canvas throw some light on this problem...?

Community Champion

The method you're using to load the content within an iframe isn't officially supported -- at least I don't remember seeing it. I think I just came up with it by looking at the URL when I was previewing a file and it worked.  Like many other things that aren't officially supported or documented, we're finding that they're coming back to bite us. The best solution is to manually update  

If you had a link to the file using what Canvas put in, then what Canvas does is change all of your links to refer to the new file when you replace an existing one. The preview=5781661 is a query parameter and not part of the pathname. Canvas hasn't been taught to look for file IDs as part of that as that's not how it generates the links.

As for good database design that was mentioned in the original message, what Canvas often does is keep all of the content but mark it as deleted or some other flag when it's no longer in use. Unfortunately, that's not what is happening right now.

What I am experiencing through the API has changed from what I believe I explained to people in the past, so you may want to file a support ticket and see if this is really what is supposed to be happening.

When I search for my old file using the API

GET /api/v1/courses/896851/files/75099867

I get the new object

"id": 110151837,
"folder_id": 9597565,
"display_name": "textbook-ch3.pdf",
"filename": "textbook-ch4.pdf",
"content-type": "application/pdf",
"url": "<redacted>",
"size": 2645200,
"created_at": "2017-07-23T05:18:21Z",
"updated_at": "2017-07-23T05:18:53Z",
"unlock_at": null,
"locked": false,
"hidden": false,
"lock_at": null,
"hidden_for_user": false,
"thumbnail_url": null,
"modified_at": "2017-07-23T05:18:21Z",
"mime_class": "pdf",
"media_entry_id": null,
"locked_for_user": false

Notice the created_at, updated_at, and modified_at dates are all for the new object, not for the old one. That means that we can't tell when the original file was put out there, just when the replacement came into existence -- and that is the part that is different, although perhaps undocumented. I found the place where I explained the dates and the current behavior does NOT match what was happening on May 5, 2017: 

Community Champion

That is really helpful,  @James ‌, and thanks as always for the information!

As  @jkhazar253 ‌ originally said, though, it is not good design, at least not for the user. Canvas is not replacing the file as the pop-up states explicitly; Canvas is deleting the old file and uploading a new file. If they are able to update all their links internally, well and good, but users who think they are replacing a file will find the hard way (broken links) that they did not replace a file. They deleted an old file and uploaded a new one, with a new file ID number.

It's bad enough having to iframe your own content in a Page, but this crosses the line with me. I cannot recommend that someone use that hack to get dynamic content into Pages. It was nice to be able to tell people it was possible, but if all it does is put people into an unsustainable trap, I cannot recommend it now that I understand this prevents people from ever updating the content.

I'll wait to see if we hear anything from the people at Instructure about this, but I don't see how I could ever recommend to people that they put themselves in a position where they have to choose between updated content and broken links. If this really is how the system works (or, rather, doesn't work), I'll warn people that they only safe way to put dynamic content into their Pages is to host their own javascript calls, not to rely on Canvas Files for that. The fabulous guys at Reclaim Hosting just charge $30 for their basic hosting package, and they totally understand and support educational users. When you control your own webspace, you can update your content without breaking links. You still have to use the ugly iframe solution in Pages (which is already pretty frustrating as opposed to the simplicity of just calling the javascript right there), but at least your links will not break! I'm really relieved that all the script calls in my Javascript WIdget Warehouse iframe snippets are to scripts in my own webspace; those are still safe for anybody to use.

I'm very disappointed about this. VERY disappointed. Other frustrations I've had with Canvas have been purely my own personal preferences not being satisfied (and hey, that's okay; I am a marginal, eccentric user), but this is far worse. Now I've got discussion posts everywhere here at the Community and blog posts in my own space where I have made this very bad recommendation to people. It's going to take forever to go back to all those posts and warn people that if they use this workaround they either cannot ever upload a new version of the file ever OR they have to manually keep track of where they link to the file so they can manually redo the link. What a mess. 

So, again I have to say THANK YOU to  @jkhazar253 ‌ for finding this out and documenting the problem here. I never would have suspected that replace is NOT replace. So, better late than never. I feel terrible for having given bad advice to people all these months, but at least I will not give bad advice like that in the future.

I'm pinging ishar-uw‌ also since she is the one who first explained this hack to me, just in case she also was not aware that it is not a sustainable hack after all. Argh................

Community Participant

Interesting. I see that using the Canvas UI to link to the file will create an automatically tracking link, but using a hand-coded URL in HTML fill fail every time the linked item is updated in the Files section. That's all well and good, but it doesn't give me the true work-around I'd been wanting to use, which is a way of displaying my own HTML pages from within Canvas. The preview=5781661 query parameter in the URL will display an .html file with all of my CSS and JavaScript markup, which is what I really (and I mean absolutely) must have. So I will live with the hand-coded updates. permalink #permalinks workarounds #custom css

Community Participant


I saw your earlier posting on iFrames (I think that was you), but iFrames in Canvas Pages can't be formatted to a useful size - they just show about 200px of height, now matter how you format them. Like I said, I'm using the Files technique to get around Canvas locking out my styling and javascript (and font loading, and svg's, and font-awesome icons). I'm hacking the system to bend it to my will. I've spent the last 15 or so years building web pages I project for my class lectures, and have used Desire2Learn, and Moodle (mrooms), both of which allow me to format my pages with my own style sheets. Canvas, as far as I can tell (and I'd love to know if there was a work around for this), locks me out of being able to control the look and feel of my Web materials. I cannot begin to express the rage and disappointment I feel about this.

As for using an outside web server, that's a problem because I don't want students to have to log in twice, and I especially don't want to deal with the copyright fair use issues and intellectual property issues that might arise if I host my own pages and make them available to the public.

copyright‌ custom css‌ #workarounds

 @jkhazar253 ‌ my need is a different one; there are services like Twitter, Flickr, and Pinterest which offer great widgets, but they are javascripts; Pages strip out the javascript call, but if you host the javascript call somewhere else, you can then iframe THAT other page into a Canvas Page. Which is already a kind of ridiculous work-around, but it does work. I was using that workaround by hosting the javascript calls in my own webspace, but then I learned that people could do that in the Files area of Canvas, as I explain here (and sadly this is just one of many places where I have urged people to use Files to get dynamic content into their Pages):

Pinterest in Canvas 

Unfortunately, as you discovered that is just not a very good idea. In the future, I will recommend that people do that only as a last resort, while urging them to get their own webspace. There's no way to avoid the way Pages strips out the javascript calls (which is annoying enough), but this Files replace-is-not-replace business is really bad.

Have you thought about hosting in your own space and then using the Redirect Tool? That is a great way to get HTML content to display in Canvas (including dynamic content, javascripts, custom css, etc.) without being limited to the really poor Canvas content tools. I like using the Redirect Tool to display the HTML clippings view from Inoreader, my RSS reader; here's how that works for me:

Blog Labels + Inoreader + Redirect Tool = Canvas Magic! 

That's a case where the content is dynamic, being generated on the fly from Inoreader; works perfectly with Redirect Tool.

Aha,  @jkhazar253 , I just saw this comment before posting my own. I rely on public domain content in my classes, so I am totally cool with having all the content be open. 

About iframes, yes, I find it completely annoying that I have to do that. I've made it work, more or less, but it's not my favorite. You can see the results I've managed to get here in this open Canvas space:

Laura's Widget Warehouse: Homepage

My widget content is generally of standard width (I design them for use in blogs), but variable height, so the iframe thing is indeed a pain. When I use the javascripts in my own blogs and wikis, I can just use the javascript; I don't have to do this iframe thing.

I understand Canvas's need for security... although I'm glad that there are other hosted services, like Blogger and PBWorks, which allow users to use javascript. That's one of the reasons why I've always recommended Blogger to my students; it has always been much friendlier to javascript than (the free hosted version, not the self-hosted WordPress).

Anyway, I share your frustration; if I were actually having to rely on Canvas to deliver content to my students, I don't know what I would do. There's really no way I could make it work... so, thank goodness for the public domain content and the open web. That's been my focus ever since I started developing online materials a gazillion years ago (I've been teaching online since 2002). Long live the public domain! 

Community Participant

iFrames just never worked for me at all in Canvas, I couldn't get any kind of vertical height on them, even with inline styling. It may be my college districts' implementation of Canvas. And I just discovered another gotcha with my preview=123456 method - any style and javascript links have to be on a secure https server or they don't work. Luckily our district does provide a secure https server I can post my css and js files on.