I am trying to download a file with custom name from any url.
I am trying this on my code
downloadAttachment(attachment) {
var a = document.createElement('a');
a.href = attachment.url; //URL FOR DOWNLOADING
a.download = 'CustomName.png';
a.click();
}
and from view it is <button (click)="downloadAttachment(attachment)"></button>
It is downloading the file but filename is still picked up from the url.
How to add custom name to the file?