Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Redirect instead of download
Browse files Browse the repository at this point in the history
This way we can not set the name of the file but the user is downloading directly from the studydrive servers and not from a proxy
  • Loading branch information
the-codeboy committed Apr 27, 2024
1 parent 71d08c7 commit f08a48e
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions templates/download.tera
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</a>
</div>
</div>
<div style="height: 50px;"></div>
<div class="container">
<div class="text-center">
<script type='text/javascript' src='https://storage.ko-fi.com/cdn/widget/Widget_2.js'></script>
Expand All @@ -34,26 +35,13 @@
</div>
</div>
<script>
document.getElementById("download").remove();
fetch("https://corsproxy.io/?"+encodeURI("{{ url }}"))
.then(response => response.blob())
.then(blob => {
let url = window.URL.createObjectURL(blob);
let a = document.createElement("a");
a.href = url;
a.download = "{{ name }}";
document.body.appendChild(a);

setTimeout(function() {
a.click();
a.remove();
document.getElementById("download").click();
document.querySelector("h1").textContent = "Download of file {{ name }} successful! This tab now will close automatically";
setTimeout(function() {
window.close();
}, 5000);
}, 1000);
})
.catch(error => console.error(error));
</script>
</body>
</html>

0 comments on commit f08a48e

Please sign in to comment.