How does one go about setting up file download in a Single Page Application, without triggering a reload?
I have had a situation where a PDF file is generated on the server and needs to be given to the client for download. Sending it as an application/octet-stream does nothing useful in a SPA, because files can't be sent over AJAX.
The best I came up with is saving the generated file in a temp folder on the server, sending file's URL to the client and doing window.open(url). The problem is that different browsers open files differently. Firefox for instance, by default, opens PDFs in the same tab, using their PDF.js, disrupting the whole SPA idea. But doing a window.open(url, '_blank') often triggers popup blockers etc. Other file types can cause God knows what...
Is there a cross-browser, safe, general method for downloading files in a SPA?