Name in iframe Random string

Discussão em 'Angular' iniciado por Carolina Castillo, Janeiro 8, 2025.

  1. In my application, i'm using iframe to view files but I have a problem. The file name is a random string and not its name. How could he manipulate that information? I need the name of the file itself to appear and when I download it the same.

    I'm using the following.

    Service

    obtenerDoc(nodeId: string, token: string) {
    const url = `${environment.proxyConfig}${this.baseUrl}/nodes/${nodeId}/content?attachment=true&alf_ticket=${token}`;
    const headers = new HttpHeaders({
    'Authorization': `Bearer ${token}`,
    'accept': 'application/octet-stream',
    });

    return this.http.get(url, {
    headers: headers,
    responseType: 'blob',
    observe: 'response'
    });
    }


    APP

    obtenerDocumentoNormal() {
    this.obtenerDoc.obtenerDoc(this.nodeId, this.token).subscribe(
    (response) => {
    const contentDisposition = response.headers.get('content-disposition');
    if (contentDisposition) {
    const matches = /filename="(.+)"/.exec(contentDisposition);
    const filename = matches && matches[1] ? matches[1] : 'desconocido.pdf';
    }
    const objectUrl = URL.createObjectURL(response.body);
    this.nodoUrl = this.sanitizer.bypassSecurityTrustResourceUrl(objectUrl);
    this.isImage = false;
    this.isAudio = false;
    this.isFrame = true;
    this.isVideo = false;
    this.isNotVisualizable = false;
    this.isLoading = false;
    },
    (error) => {
    console.error(error);
    MessageUtil.showAlertMessage("No se puede visualizar este tipo de documento");
    }
    );
    }


    HTML

    <iframe *ngIf="isFrame" [src]="nodoUrl" class="container__frame" name="documento" title="nombre"></iframe>



    In the content -disposition I have the name but that is not in the browser blob and I suppose that is why it takes a random name

    Continue reading...

Compartilhe esta Página