Angular Chrome阻止blob对象并显示下载的文件是危险的

Angular Chrome阻止blob对象并显示下载的文件是危险的,angular,spring-boot,google-chrome,blob,Angular,Spring Boot,Google Chrome,Blob,我正在从服务器下载文件,然后在收到响应后使用blob下载文件。该文件的类型为tar.gz,但google chrome浏览器显示警告,因为“xyz.tar.gz不常下载,可能很危险”,有时还显示“xyz.tar.gz可能很危险,所以chrome已经阻止了它”。我想在chrome中避免这个警告,也不想更改chrome的任何设置,比如取消选中安全浏览选项 Code in Component.html file <button class="download-link" (click)="dow

我正在从服务器下载文件,然后在收到响应后使用blob下载文件。该文件的类型为tar.gz,但google chrome浏览器显示警告,因为“xyz.tar.gz不常下载,可能很危险”,有时还显示“xyz.tar.gz可能很危险,所以chrome已经阻止了它”。我想在chrome中避免这个警告,也不想更改chrome的任何设置,比如取消选中安全浏览选项

Code in Component.html file
<button class="download-link" (click)="downloadFile('/supportbundleDownload/20190710')">Click here to download the logs.</button>


Code in component.ts file
downloadFile(url:string) {
        var sequenceNumber = url.substring(url.lastIndexOf('/') + 1, url.length);
        this.SomeService.downloadFile(url).subscribe(response=> {
            var fileName = "logs_complete_" + sequenceNumber + ".tar.gz"
            var newBlob = new Blob([response], { type: "application/gzip" });
            if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                window.navigator.msSaveOrOpenBlob(newBlob, fileName);
              }
            else {
                var a = document.createElement('a');
                a.href = URL.createObjectURL(newBlob);
                a.download = fileName;
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
              }
        })


Code in component.service.ts
downloadFile(url: string): Observable<Blob> {
        return this.http.get(url);
    }

The file is getting downloaded but chrome is blocking it and showing the warning. The file type is .tar.gz
Component.html文件中的代码 单击此处下载日志。 component.ts文件中的代码 下载文件(url:string){ var sequenceNumber=url.substring(url.lastIndexOf('/')+1,url.length); 此.SomeService.downloadFile(url).subscribe(响应=>{ var fileName=“logs\u complete\u”+sequenceNumber+”.tar.gz” var newBlob=newBlob([response],{type:“application/gzip”}); if(window.navigator&&window.navigator.msSaveOrOpenBlob){ window.navigator.msSaveOrOpenBlob(newBlob,文件名); } 否则{ var a=document.createElement('a'); a、 href=URL.createObjectURL(newBlob); a、 下载=文件名; 文件.正文.附件(a); a、 单击(); 文件.body.removeChild(a); } }) component.service.ts中的代码 下载文件(url:string):可观察{ 返回此.http.get(url); } 该文件正在下载,但chrome正在阻止它并显示警告。文件类型为.tar.gz