title: How to download image from URL (using blob) in angular 5
body: <p>I have few links in my web application , some of them have <code>content type</code> <code>application/pdf</code> and some <code>image/jpeg</code> on click downloads/saves file (respective type)</p>
  
  <p>I have an issue while downloading images, but the following code works perfectly for application/pdf, </p>
  
  <p>I need help in downloading images from URL. I tried changing <code>Content type</code> and response type to <code>image/jpeg</code> but it's not working.</p>
  
  <pre><code>downloadDocFile(fileLocation, fileName) {
  
  var fileNAme = fileName;
  var url = fileLocation;
  
  let headerD = this.service.getHeaderDict();
  
  const headerDict = {
    'Content-Type': 'application/pdf',
    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE',
    'Access-Control-Allow-Headers': 'Authorization, X-Requested-With, Content-Type, Origin, Accept, X-clientid, X-locale, X-loggedin, X-version',
    'Access-Control-Allow-Credentials': true
  }
  
  const requestOptions = {
    headers: new Headers(headerDict), responseType: ResponseContentType.Blob
  };
  
  const proxyurl = "https://cors-anywhere.herokuapp.com/";
  
  this.http.get(proxyurl +url,requestOptions).subscribe(
    res =&gt; {
      const data: Blob = new Blob([res.blob()], { type: 'application/pdf' });
      saveAs(data, fileNAme);
   })}
  </code></pre>
  
  <p>service.ts</p>
  
  <pre><code>getHeaderDict(): Object {
       return this.headerDict
  }
  </code></pre>