Angular 4 turn blob into pdf and show in tag object

0

I have an application, currently angular 4, and would like to be able to upload files saved in the bank into formed Blob. the command below works correctly and downloads the file.

   downloadArquivoAnexo(documento: Documentos){

    if(!documento){
      this.mensagem.open("Nenhum arquivo encontrado.", 'X', {duration: 5000});
    }else{
        var byteCharacters = atob(documento.conteudo);
        var byteNumbers = new Array(byteCharacters.length);
        var a = document.createElement("a");
        document.body.appendChild(a);
        for (var i = 0; i < byteCharacters.length; i++) {
            byteNumbers[i] = byteCharacters.charCodeAt(i);
        }
        var byteArray = new Uint8Array(byteNumbers);
        var blob = new Blob([byteArray], {type: this.extensaoArquivos[documento.tipo].extensao});
        var url= window.URL.createObjectURL(blob);
        a.href = url;
        a.download = "teste."+this.pontoArquivo.find(x => x.id == documento.tipo).extensao;
        a.target="_blank";
        a.click()
    }
}

I just want it to be shown inside a component when the button is clicked.

  <object id="contentFile" data="" width="100%" height="600px" type="application/pdf">
            </object>

The problem is that I can not get a way to insert the correct data in date to display the blob, if I use a fixed url it works correctly.

I would like to know how to solve this problem for dynamic urls formed by blob: http. With them I can only download, never show the file on the page as in the image above.

    
asked by anonymous 30.01.2018 / 15:40

0 answers