// Angular Solution
//html
<button type="button" class="btn btn-sm btn-warning"
(click)="downloadArchiveFile(item.file_name, downloadSrc+item.url)">
Download
</button>
//typescript
import { HttpClient } from '@angular/common/http';
///
constructor(private http: HttpClient) {}
///
downloadArchiveFile(name: string, url: string) {
this.loader.start();
this.http.get(url, { responseType: 'blob' })
.subscribe((data: any) => {
this.loader.stop();
console.log(data);
this.download(name, data);
}, (error) => {
this.loader.stop();
this.toastr.error(error, "Something Went Wrong");
});
}
download(name, blob) {
let link = document.createElement("a");
link.download = name;
link.href = URL.createObjectURL(blob);
link.click();
}