Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
angular2 download object using pre-signed url from s3

I'm using the AWS SDK to generate pre-signed download url from S3 and and I have already done that part. I can copy the generated pre-signed url into browser and the chrome will automatically download the file.

I want to achieve the same thing in Angular2, basically simulate clicking that link. So I wrote the following code:

app.component.ts

public downloadFile() { 
  this.downloadService.downloadFile(this.downloadLink)
    .subscribe((response) => {
      console.log(response);
    });}

download.service.ts

    public downloadFile(downloadLink: string) {
      return this.http.get(downloadLink)
        .map((response) => {
            return response;
      });
    }

It indeed printed out the file content in the console but it didn't trigger the downloading. Has anybody got an idea what's the correct way to do it?

Thanks,

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Here is an example to download a CSV file change the mime type for your own file.

public downloadFile(downloadLink: string) {
      return this.http.get(downloadLink)
        .map((response) => {
           let blob = new Blob([response], { type: 'text/csv' });
           let url= window.URL.createObjectURL(blob);
           window.open(url);
      });
    }
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda