I can download files from my server. After a lot research I found this method in javascript:
fetch("requestUrlToFile",
{
method: "GET",
headers: {
"authorization": "jwt"
}
})
.then(checkStatus)
.then(function(res){
return res.blob();
})
.then(function(blob){
var filename = "PdfName-" + new Date().getTime() + ".pdf";
if (typeof window.navigator.msSaveBlob !== 'undefined') { // IE
var blob = new Blob([blob], { type: 'application/pdf' });
window.navigator.msSaveBlob(blob, filename);
} else {//if (typeof window.chrome !== 'undefined') { // Chrome
var link = document.createElement('a');
link.id = "download_" + billingId;
link.className = "hidden";
link.href = window.URL.createObjectURL(blob);
link.download = filename;
$downloads.appendChild(link);
link.click();
$downloads.innerHTML = "";
}
});
This works in all modern browsers (IE 10+, Edge, FF, Chrome, Opera). But Safari and mobile browsers don't work.
Can you help me with it?