this.repositoryApiService.export(repoType, repoItem, type)
.subscribe((data: any) => {
this.commonService.downloadFileFromServer(data.serverPath, data.name);
}, error => {
console.error(error);
});
}
downloadFileFromServer(serverUrl: string, fileName: string) {
const a = document.createElement("a");
document.body.appendChild(a);
a.setAttribute("style", "display: none");
a.href = serverUrl;
a.download = fileName;
a.click();
a.remove(); // remove the element
}
我从服务器获取的数据包含url