Angular 19: Observable Http File Download ends prematurely

Discussão em 'Angular' iniciado por Eman4real, Fevereiro 14, 2025.

  1. Eman4real

    Eman4real Guest

    I have a service to download a file and a component to handle downloading it. The download happens and returns a 200 with the blob data but the observable ends immediately. As soon as the http call finishes, no other RXJS operators or subscribes fire. I'm at a loss on this one.

    I can't provide full code but I can answer questions or provide obfuscated versions of code.

    Node 22.13
    WSL Ubuntu 24.04
    Angular 19.0.6
    RxJs 7.8.0

    Service

    downloadAttachment(id: string, fileName: string) {
    return this.url$.pipe(
    mergeMap(url => this.httpClient.get<Blob>(`${url}/attachment/${id}`)),
    );
    }


    Component

    handleDownloadClick(id: string) {
    this.noteService.downloadAttachment('some-id', 'random
    file.pdf').subscribe(() => {
    // console doesn't happen
    console.log('data');
    });}

    Continue reading...

Compartilhe esta Página