Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 new HttpClient content-disposition header

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

like image 708
Tobias Etter Avatar asked Nov 07 '17 14:11

Tobias Etter


1 Answers

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.

like image 89
kair Avatar answered Sep 18 '22 09:09

kair