i'm trying to download pdf file from my server response into the client side using jQuery. My code works fine for Windows, Android, Linux on Chrome & Mozilla - i.e. able to download pdf data file with correct name and able to open it.
But on iOS devices (iphone, ipad, etc) in Safari and Chrome able to get popup for file download with "document" name, not as name specified by me in code. Also the file is saved without any extension and have added this header - Content-Disposition: attachment; filename="MyFileName.ext"
These all stuff happening in iOS only. Below is the code i'm using for downloading pdf document in iOS
var reader = new FileReader();
var parsedData = JSON.parse(response);
var parsedResult = _base64ToArrayBuffer(parsedData[0])
var blobOutput = new Blob([parsedResult], { type: 'application/pdf' });
var documentLink = document.createElement('a');
documentLink.style = "display: none";
reader.onload = function (e) {
documentLink.href = reader.result;
documentLink.download = parsedData[2]; // contains file name
document.body.appendChild(documentLink);
documentLink.click();
}
reader.readAsDataURL(blobOutput);
This is the screenshot on iOS 13 device of browserstack.
Also checked that apple has fixed this bug here, but i'm unable to get it work.
Any help on this will be much appreciated. Thanks in advance!