3

我正在使用 blob 在新选项卡中查看文件(无特定类型)。如果支持文件预览,则该文件是可查看的。但是,如果不支持该文件,则会下载该文件。是否可以使用自定义文件名而不是使用 createObjectURL 生成的随机名称来阻止它下载或下载?

download(image: Blob) {
const url = window.URL.createObjectURL(image);
window.open(url);
}



this.http.post<Blob>(**APILink**, data, { headers: {token details}, responseType: 'blob' as 'json' }).subscribe((response) => {
  this.download(response);
}
4

0 回答 0