After an outage on September 1, the Instructure Community is now fully available, including guides, release notes, forums, and groups. If some styling still looks unusual, clear your cache and cookies.
I'm currently trying to download files using the canvas API and I'm having an issue with the file's url. In every explanation that I can find the url follows this structure:
"http://<canvas>/files/<id>/download?download_frd=1&verifier=[verifier]"
But every time I look up the information of a file in my organization, I never get the verifier with it. The structure I always get looks like this:
"https://<canvas>/files/<id>/download?download_frd=1"
I don't know if there's something that I'm missing or maybe my organization doesn't allow access to files with this type of user validation
Thanks in advance
I don't see a verifier when I look at the API results either, at least not with the couple I tested.
If you are working with JavaScript, you could use the URL to create an anchor tag that opens in a new tab and then simulate a click on it. After clicking it you could remove the anchor tag.
function downloadCanvasFile(url) {
let downloadAnchor = document.createElement("a");
downloadAnchor.href = url;
downloadAnchor.target = "_blank";
document.body.appendChild(downloadAnchor);
downloadAnchor.click();
document.body.removeChild(downloadAnchor);
}
downloadCanvasFile("https://<canvas>/files/<id>/download?download_frd=1");
If you want to rename the file before downloading, you can use the download attribute, but you will also have to strip away the download part of the URL after the id.
function downloadCanvasFile(url, filename) {
let downloadAnchor = document.createElement("a");
downloadAnchor.href = url;
downloadAnchor.download = filename;
downloadAnchor.target = "_blank";
document.body.appendChild(downloadAnchor);
downloadAnchor.click();
document.body.removeChild(downloadAnchor);
}
downloadCanvasFile("https://<canvas>/files/<id>/download?download_frd=1", "desiredFilename.fileExtension");
I only tested in Chrome, so I'm not sure if this is fully supported in other browsers.
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.