Jump to content
Fórum Script Brasil
  • 0

Download de qualquer arquivo em angular 9



     download(idArquivo: number): void {
           data => {
             const blob = new Blob([data.arquivo], { type: 'text/json; charset=utf-8' });
             const url= window.URL.createObjectURL(blob);
           err => {
     import { HttpClient, HttpHeaders } from '@angular/common/http';
     import { Injectable } from '@angular/core';
     import { SERVER_API_URL } from 'app/app.constants';
     import { Observable } from 'rxjs';
         providedIn: 'root'
     export class ArquivosService {
             private http: HttpClient
         ) {}
         downloadArquivoOrcamento(id: number, tipo: string): Observable<any> {
             return this.http.get(SERVER_API_URL + '/api/orcamento-anexo/' + id, 
                 responseType: 'blob',
                 headers: new HttpHeaders().append('Content-Type', tipo)
Retorno do backend

Não retorna o arquivo conforme imagem anterior
Dowload com erro


Já pesquisei e fiz alguma alteração, mas não achei a solução. O que quero é simples. O arquivo vem do backend em bytesm nome e content-type. Só quero fazer o dowload.

O que pode ser ?

Edited by Netsoft
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...