Hi, I went through the same problem as you.
Here is the JS Script with I use to solve this problem:
""" (async function download() {
javascript: var xhr = new XMLHttpRequest();
xhr.open('GET', '(absoluteUrl)', true);
xhr.setRequestHeader('Content-type','application/octet-stream');
xhr.responseType = 'blob';
xhr.send();
xhr.onload = await function(e) {
if (this.status == 200) {
var blobFile = this.response;
var reader = new FileReader();
reader.readAsDataURL(blobFile);
reader.onloadend = function() {
base64data = reader.result;
window.webkit.messageHandlers.getBase64FromBlobData.postMessage(base64data);
}
}
};
})();
"""
I use this two links as reference:
https://www.programmersought.com/article/78896496442/
https://stackoverflow.com/questions/59083340/how-to-download-files-in-wkwebview
I hope it help you