What I actually want is to make something like Mega web, where when you download a file, first it downloads it inside your browser, then your browser prompts to actually download the file and the file will be downloaded instantly.
So far this is what I've found as a solution:
fetch(url).then(response => response.text())
.then(uri => {
var link = document.createElement("a");
link.download = name;
link.href = uri;
link.click();
})
while it works for small pictures, I've tried this approach on a 80mb file, and the tab crashed.
I haven't tested this yet but apparently this is working:
fetch(url)
.then((response) => response.blob())
.then((blob) => {
var URL = window.URL || window.webkitURL;
var fileURL = URL.createObjectURL(blob);
var link = document.createElement("a");
link.download = name;
link.href = fileURL;
link.click();
URL.revokeObjectURL(fileURL);
});