title: Angular 2 Download File from URL
body: <p>Hi I have connected my Angular/Ionic 2+ app to Amazon S3. In my app when I want to download a file my backend delivers a unique pre-signed URL generated from my S3. Looks something like this:</p>
  
  <p><a href="https://s3.ap-southeast-2.amazonaws.com/test%2F1/435345345-4545-4aa8-8a8a-etertertttrt-4addd157-ac38-41fd-5454-8ffa709ee77fcsdfsdfa" rel="nofollow noreferrer">https://s3.ap-southeast-2.amazonaws.com/test%2F1/435345345-4545-4aa8-8a8a-etertertttrt-4addd157-ac38-41fd-5454-8ffa709ee77fcsdfsdfa</a>...</p>
  
  <p>My question is how do I download the file programatically through my component once I have the url? I have tried so far without luck:</p>
  
  <pre><code>window.open(url, '_blank');
  </code></pre>
  
  <p>And</p>
  
  <pre><code>getFile(url: string): void {
      this.http.get(url)
      .map((res) =&gt; {
          return new Blob([res.blob()], { type: 'image/jpeg' })
      })
      .subscribe(res =&gt; {
        saveAs(res,'test.jpg');
        let fileURL = URL.createObjectURL(res);
        window.open(fileURL);
      }, error =&gt; {
          console.log(error);
      });
      console.log('Get File http');
    }
  </code></pre>
  
  <p>With the above code I get an error: The request body isn't either a blob or an array buffer.</p>
  
  <p>Appreciate any help on this thanks..</p>