I want to open a file (format could vary between things like .docx, .pdf and .jpg) in a new window when someone clicks on a button. However, the URL where the file is located can return either the file, when I use the header {"Accept" : "application/octet-stream"}
, or it can return a JSON file with data when using the header {"Accept" : "application/json"}
.
When I do
window.open(myUrl);
I cannot specify if I get my octet-stream or json. How can I add my header, or otherwise ensure that I get the proper file?