angular - angular2 download object using pre-signed url from s3 -


i'm using aws sdk generate pre-signed download url s3 , and have done part. can copy generated pre-signed url browser , chrome automatically download file.

i want achieve same thing in angular2, simulate clicking link. wrote 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 file content in console didn't trigger downloading. has got idea what's correct way it?

thanks,

here example download csv file change mime type 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);       });     } 

Comments

  1. In this article, we discuss Download multiple files using S3 pre-signed URL in my Angular Application

    https://www.thestackoverflow.com/question/download-multiple-files-using-s3-pre-signed-url-in-my-angular-application/

    ReplyDelete

Post a Comment