These seem to be the only two existing approaches.
the issue with createObjectURL() is that it is deprecated, my current browser, chrome can't even call this method anymore.
the issue with FileSaver is that it feels overkill to add a whole library to your project when realistically it should only take a few lines to do it natively in angular.
here's were I'm at :
const params = {'params' : p}; const httpOptions = this.authenticationService.getRequestOptions(); httpOptions['responseType'] = 'text/csv'; this.http.post( this.url + this.currentId, params, httpOptions ).subscribe((response: any) => { console.log(response); const blob = new Blob([response], {type: 'text/csv'}); const link = document.createElement('a'); link.setAttribute('style', 'display: none'); link.href = response; // should be a URI but document.URL.createObjectURL() is deprecated const date = new Date(); link.download = 'file.csv'; link.click(); link.remove(); }, error => { console.log('I failed :(', error); }); this does indeed trigger the download of a file. but I need the blob converted to URI and I don't have that part.
EDIT :
Just for clarity :
As of TODAY 19/11/2019 and since 1/11/2017, window.URL.createObjectURL is deprecated and will return an error : https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
UPDATE :
I found this :
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
https://code-examples.net/en/docs/dom/htmlmediaelement/srcobject
it's supposed to be the replacement for createObjectURL but it only works for video elements