Hi All,
I am just checking on any file download from server.
Below code is working on browser but not in APP.
Seems that below code not working
document.body.appendChild(downloadLink);
downloadLink.click();
My full code:-
downloadFile(directory: string, filename: string = null): void {
const baseUrl = this.service.Base_Url + 'download.php?dir=files/' + directory + '/&file=' + filename;
this.service.process_download(baseUrl).subscribe(
(response: any) => {
//Check Blob size | File is available or not
if (response.size > 0) {
let dataType = response.type;
let binaryData = [];
binaryData.push(response);
let downloadLink = document.createElement('a');
downloadLink.href = window.URL.createObjectURL(new Blob(binaryData, { type: dataType }));
if (filename) {
downloadLink.setAttribute('download', filename);
}
document.body.appendChild(downloadLink);
downloadLink.click();
}
}
)
}
Please suggest on this.
1 post - 1 participant