Angular 4 new HttpClient content-disposition header
22,444
I had the same Issue and found this https://stackoverflow.com/a/45482346/1909698
It worked for me after adding 'Access-Control-Expose-Headers': 'Content-Disposition'
in my backend response header.
Related videos on Youtube
Author by
Tobias Etter
Updated on July 09, 2022Comments
-
Tobias Etter almost 2 years
I am trying to get a file (array buffer) from my backend using the new HttpClient.
My code is pretty much like the following:
this.http.post(url, body, {responseType: 'blob', observe: 'response'}) .subscribe(resp => { console.log(resp.headers.get('content-disposition')); });
The repsonse in my browser console is null
When I take a look at the network tab, then I see that content-disposition has a value like attachment; filename="whatever"
If I try to get content-type instead, then I receive something.
Have you experienced something similar or can you tell me what I have to do else? Many thanks
-
Tobias Etter over 6 yearsthere is a relation to stackoverflow.com/questions/46389488/… but I could not solve it yet
-
-
Tobias Etter over 6 yearsThat was exactly what I searched for. Solved my problem. Thank you =)
-
Ross over 5 yearsThanks! This was also useful: stackoverflow.com/questions/38897764/…
-
MG Developer about 5 yearsThanks great find, the issue is so misleading because in browser you see the content-disposition but angular does not see it until you tell the server specifically to expose the specific header.
-
Bernoulli IT over 2 yearsI didn't need 'Access-Control-Expose-Headers': 'Content-Disposition' in Angular 12 (anymore?!)