title: Dowload PDF as a stream of bytes
body: <p>I have web API that provides stores files as a stream of bytes. The response is already fetched and saved in the state but now I want to download the file from my react application onClick of a button. I am doing it as follow:</p>
  
  <pre><code>downloadContract( binaryData ) {
          const file = new Blob([binaryData], { type: 'application/pdf' });
          const fileURL = URL.createObjectURL(file);
          window.open(fileURL);
        }
  </code></pre>
  
  <p>The stream is being fetched correctly after debugging but downloading the file produces an error:
  <strong>Error loading PDF document.</strong></p>
  
  <p>Update:</p>
  
  <p>New endpoint calling using this source:</p>
  
  <pre><code>  callLoadContract: {
      remote( state, id, contractId ) {
        const url = `${base}/vendor/${id}/${contractId }`;
        return $http.instance.api.get( url, id, contractId);
      },
      success: Actions.contractLoaded,
      error: Actions.fail
    }
  </code></pre>
  
  <p>Handling the response: </p>
  
  <pre><code>  loadContract({id, contractId}) {
      this.getInstance().callLoadContract( id, contractId );
    }
  
    contractLoaded( response ) {
      if (response &amp;&amp; response.data) {
        console.log(response);
        const file = new Blob([response.data], { type: 'application/pdf' });
        const fileURL = URL.createObjectURL(file);
        window.open(fileURL);
      }
    }
  </code></pre>
  
  <p>Same error.</p>