Sub topic 11
Delivering files and controlling access
You have chosen which downloadable resources belong in your course and prepared them in suitable formats. This chapter covers how learners receive those files and who is allowed to get them. It assumes you know the basics of a course platform and have a finished file ready to publish. The code examples assume you can read short JavaScript and HTML.
What delivery has to get right
A file that exists but cannot be opened is worse than no file. Delivery has four jobs:
- Findability: the learner sees the file at the point in the lesson where it is useful.
- Reliability: the link works on every device and keeps working after you update the course.
- Access control: only the right people can download it, such as paying learners or learners who have reached a given module.
- Clear expectations: the learner knows what the file is before clicking.
These jobs sometimes conflict. Strict access control can break a link that a learner bookmarked. A very reliable public link can leak to non-customers. Decide which risk matters more for each file.
Three ways to deliver a file
| Method | How it works | Good for | Main weakness |
|---|---|---|---|
| Platform attachment | You upload the file to the lesson. The platform stores and serves it. | Most courses. Access follows enrollment automatically. | Limited control over file size, naming, and download counts. |
| Link to external storage | The lesson links to a file in cloud storage or a shared drive. | Large files, or files you update often. | You must manage access and link expiry yourself. |
| Email or message delivery | The platform sends the file or a link after an event, such as finishing a module. | Certificates, bonus material, tickets. | Emails get lost in spam folders. The file is detached from the course. |
Start with platform attachments. Move to external storage only when file size or update frequency forces you to.
Writing a link that sets expectations
Name the file, its format, and its size in the link text. Learners on mobile data decide whether to download based on size. Screen reader users also hear the link text out of context, so it must make sense alone.
<a href="/downloads/module-2-worksheet.pdf" download="module-2-worksheet.pdf">
Download the Module 2 worksheet (PDF, 240 KB)
</a>The download attribute asks the browser to save the file instead of opening it. It only works for same-origin links, meaning files served from your own domain. For a cross-origin link, the browser ignores the attribute and may open the file in a tab. If you need a forced download from external storage, the storage service must send a Content-Disposition: attachment response header.
Use stable, descriptive file names such as module-2-worksheet.pdf. Avoid spaces, final_v3, and dates in the name. When you revise a file, keep the same URL and replace the content. This keeps old links and bookmarks working.
Access control models
Access control decides who may download a file. There are four common models.
- Public. Anyone with the link can download. Use this for free samples that help marketing.
- Enrolled only. The platform checks that the learner is enrolled before serving the file. This is the default for paid courses.
- Progress-gated. The file unlocks when the learner finishes a prerequisite, such as a quiz. Use it for answer keys or advanced templates.
- Time-limited. The link works for a set period. This limits sharing outside the course.
A hidden URL is not access control. If a file sits at a public address and the only protection is that the link is not shown on the page, anyone who guesses or shares the address can fetch it. Search engines may also index it. The server must check permission on every request.
Signed links for externally stored files
If your files live in cloud storage, a signed link is the usual way to combine reliability with control. The platform creates a link that includes an expiry time and a signature. The storage service rejects the link if the expiry has passed or the signature does not match.
Here is a small Node.js example of the signing idea. It uses only built-in modules. Set the LINK_SECRET environment variable before running it, and run it as an ES module.
import { createHmac, timingSafeEqual } from "node:crypto";
const SECRET = process.env.LINK_SECRET;
if (!SECRET) throw new Error("Set LINK_SECRET first");
function sign(path, userId, expires) {
return createHmac("sha256", SECRET)
.update(`${path}|${userId}|${expires}`)
.digest();
}
export function makeLink(path, userId, ttlSeconds = 900) {
const expires = Math.floor(Date.now() / 1000) + ttlSeconds;
const sig = sign(path, userId, expires).toString("hex");
return `${path}?user=${encodeURIComponent(userId)}&expires=${expires}&sig=${sig}`;
}
export function isValid(path, userId, expires, sigHex) {
if (Number(expires) < Date.now() / 1000) return false;
const expected = sign(path, userId, expires);
const given = Buffer.from(sigHex, "hex");
return given.length === expected.length && timingSafeEqual(given, expected);
}
const link = makeLink("/downloads/module-2-worksheet.pdf", "learner-42");
console.log(link);Three details matter here. The signature covers the path, the user, and the expiry, so changing any of them breaks it. The comparison uses timingSafeEqual so an attacker cannot learn the signature byte by byte from response timing. The secret stays in an environment variable and never appears in the course or in the repository.
Most cloud storage services offer this feature already, often called presigned or signed URLs. Use the built-in version where you can. The code above only shows the mechanism.
Choosing an expiry time
A short expiry limits sharing but frustrates learners who open a lesson, leave, and come back. Generate the signed link when the learner clicks the button, not when the page loads. Then a 10 to 15 minute expiry is safe, because the learner uses the link right away. If you generate links at page load, a long-lived tab will hold an expired link.
Common failure modes
- Link rot. An external file moves or is deleted, and the lesson shows a 404 error. Fix this by using stable URLs and checking every link before launch.
- Over-sharing. One paying learner posts a public link to the file. Signed, expiring links reduce this. Watermarking the PDF with the learner's name discourages it further.
- Locked-out learners. A progress gate fails because a quiz attempt did not register, and the learner cannot get the file they need. Always give learners a way to contact support, and log gate decisions so you can diagnose them.
- Stale copies. You fix an error in a worksheet, but learners still hold the old file. Put a version or revision date inside the file, for example in the footer.
- Large files timing out. Videos and datasets over a few hundred megabytes fail on weak connections. Split them, offer a compressed version, or provide a resumable download from external storage.
Checking your delivery
Run these checks for each file before launch:
- Open the link while signed in as an enrolled learner. It should download.
- Open it in a private window with no session. It should be refused, unless the file is meant to be public.
- Open it as a learner who has not reached the unlock condition. It should be refused.
- Wait past the expiry and retry a signed link. It should fail.
- Try the link on a phone. Confirm the file opens in a usable app.
Exercise
A course stores its answer keys in cloud storage. The keys should only be available to learners who have passed the module quiz, and a learner who shares the link should not give access to everyone. Which delivery approach fits, and why is simply hiding the URL not enough?
Show answer
Use progress-gated access with a signed, time-limited link. The platform checks that the learner passed the quiz, then generates a link at click time that expires after a short period (about 15 minutes) and is tied to that learner. Hiding the URL is not enough because anyone who obtains or guesses the address can download the file, and the server never checks permission. A signed link makes the storage service verify the signature and expiry on every request.