Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!