From f46860443812595a846f34de65522848e7b5e0df Mon Sep 17 00:00:00 2001 From: gator Date: Fri, 18 Sep 2026 01:57:19 +0000 Subject: [PATCH] Make Download actually download The `download` attribute is ignored by every browser when the href is cross-origin, and the file we redirect to is signed with an inline disposition - so clicking Download opened the mp4 in a tab instead of saving it. ?dl=1 asks the worker to serve it as an attachment. --- videos.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/videos.html b/videos.html index 7e838c3..c37914d 100644 --- a/videos.html +++ b/videos.html @@ -71,7 +71,15 @@ function card(p) { cta += 'Edit'; cta += 'Download'; + + esc(dlUrl(p.video_url)) + '" download>Download'; + } + + // `download` on a cross-origin link is ignored by the browser, and the + // storage URL is signed with an inline disposition, so a click just opened + // the video. Asking the worker for ?dl=1 makes it serve an attachment. + function dlUrl(u) { + u = String(u || ""); + return /\/media\/[0-9a-fA-F-]{16,}$/.test(u) ? u + "?dl=1" : u; } // Through our own domain, so an open is a page load we can count. A link