Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

249
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda