rustypaste
rustypaste copied to clipboard
Forced download link on MIME override file
Hello,
Is there a way to force the file to be downloaded when a file type has the MIME override enabled for that type? I want to be able to share the link to a file that would play in the browser (like .mp4) but also share a link that will auto-download as well (like with a flag in the URL or something similar). I thought I had seen this feature somewhere in this project but can't seem to find any documentation on it if it does exist.
Thanks!
Hello!
This feature currently does not exist. You can only override the MIME types and file will be previewed or downloaded based on your browser settings. However, what you have suggested sounds interesting. Do you mean like a ?download=1 flag/parameter in the URL?
Gotcha. That's precisely what I'm talking about though. It would be nice to add that kind of flag to the URL to temporarily override any overrides (haha) that might be in place.
Hey, I implemented this in 99ac6156a8eafadee09fcba978f8353f4e9829ed
$ curl -s -o /dev/null -w '%{content_type}\n' $server/file.txt
text/plain; charset=utf-8
And when you specify download=true:
$ curl -s -o /dev/null -w '%{content_type}\n' $server/file.txt?download=true
application/octet-stream
This will force the browser to download the file.
Hope this helps! 🐻
Just a random question: Is this expected to be cross-browser thing? On my test the file is downloaded on chrome but firefox insists on playing it: example
I don't have Firefox but wanted to add that I have tested it working on Safari
Just a random question: Is this expected to be cross-browser thing? On my test the file is downloaded on chrome but firefox insists on playing it: example
Yeah I got the same result. The content type seems to be correct (application/octet-stream) so I'm not sure what is happening there.