1

the error occur when i try to download anything bigger than 50kb. I tried a lot of ways: using standard angular http client, xhr request, xhr request in zone.runOutsideAngular. But seams to get the same mistake every time. But when i tested same request from vanilla javascript it worked like a charm. Text of my request looks like this.

this.zone.runOutsideAngular(() => {
    let url = environment.backEndHttpsUrl + 'some_backend_path';
    this.xhr.withCredentials = true;
    this.xhr.responseType = 'blob';
    this.xhr.open('GET', url, true);
    const fileName = 'some name constructing method';
    this.xhr.onload = () => {
      console.log(this.xhr.response);
      let blob = this.xhr.response;
      FileSaver.saveAs(blob, fileName);
    };
    this.xhr.send();

  });

method using angular httpClient :

return this.http.get(environment.backEndHttpsUrl + 'some request building logic',
  {
    withCredentials: true,
    responseType: 'blob',
  }).toPromise()
Dmitry Yanet
  • 136
  • 1
  • 1
  • 7
  • Possible duplicate of [Javascript - ERR\_CONTENT\_LENGTH\_MISMATCH](https://stackoverflow.com/questions/22183859/javascript-err-content-length-mismatch) – Neji Soltani Jan 25 '18 at 14:03

0 Answers0