There is an Angular 6 app having a feature to download pdf files. It uses REST API from another Spring Boot application to download files.
The requirement is that i need to open pdf file in new tab and while saving it shall have a meaningful name.
I am able to get the file downloaded and open in new tab too. But while saving the file, it takes name from the url.
I tried by opening the file directly from REST API in browser and save it as well as getting blob and open in new window from angular app. Both open the files but while saving they take name from URL.
Angular - Open blob in new window blob:https://defg.com/89a0396e-994b-43d0-b3e3-aaa95d47db9f If i try to download opened file, it suggests to save with name 89a0396e-994b-43d0-b3e3-aaa95d47db9f.pdf Is there a way to pass or set filename in below approach?
var fileURL = window.URL.createObjectURL(file); window.open(fileURL, "_blank");
API - Takes Encrypted name https://abcd.com/ws/fileDownload/85C1E5010AFAE309E89534FAC594C9110D74FED4DF78AAA8EE199C78B570FABF8BC6640F0563778DD963 If i try to download opened file, it suggests to save with correct name for first time, shows string from url as name from second attempt, 85C1E5010AFAE309E89534FAC594C9110D74FED4DF78AAA8EE199C78B570FABF8BC6640F0563778DD963.pdf
Inspected response, headers look good,
Content-Disposition: inline; filename= "test.pdf"
Any suggestions would be helpful. Thanks in advance.
filename
in theContent-Disposition
header is ignored if the disposition is not "attachment". – Pointy