Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

asadbekDev's avatar

Download file

When the download starts it should show the default browser download progress but in my code when the whole file is downloaded it shows in browser's left bottom side

`​`` getFileAsAttachment(fileID: string) { let requestHeader: HttpHeaders = new HttpHeaders({ 'Authorization': 'Bearer ' + JSON.parse(localStorage.getItem('auth'))?.access_token, 'Content-Disposition': 'attachment' })

this.downloadFile(fileID, requestHeader)
  .subscribe(
    (res: any) => {
      let fileName = res.headers.get('content-disposition').split(';')[1].split('filename')[1]
        .split('=')[1].replaceAll('"', '');
      const blob = new Blob([res.body], { type: res.type });
      saveAs(blob, fileName);
    });

}

downloadFile(fileID: any, header: HttpHeaders): Observable<HttpResponse<Blob>> { return this.http.get<Blob>(${this.fileDownloadApi}${fileID}, { headers: header, observe: 'response', responseType: 'blob' as 'json' }) }

`​``

0 likes
3 replies
kiwi0134's avatar

What exactly do you mean by "show the default browser download progress" and "it shows in browser's left bottom side"?

Firefox shows a popup in the top right corner while most Chromium based browsers show it in a bar at the bottom.

asadbekDev's avatar

@kiwi0134 for example when download start in browser shows 1hour left smth, but in my case its not showing like this when whole file downloaded it shows immediatly not like this download start in browser shows 1hour left smth

kiwi0134's avatar

@asadbekDev You have enormous throughput in your local development environment. Downloads can be nearly instant, as it's merely just copying the file on your harddrive.

Please or to participate in this conversation.