我有一个Spring Boot应用程序,该应用程序提供100幅通过StreamingResponseBody压缩并发送的图像,有没有办法从有角度的应用程序中使用此服务?
<script type="text/javascript">
$(document).on('click', '.btn_delete', function(){
// var id=$(this).data("id3");
var el = this;
var id = this.id;
var splitid = id.split("_");
// Delete id
var deleteid = splitid[1];
if(confirm("Are you sure you want to delete this?"))
{
$.ajax({
url:"path.....",
method:"POST",
data:{id:id},
dataType:"text",
success:function(data){
$(el).closest('tr').css('background','#d31027');
$(el).closest('tr').fadeOut(800, function(){
$(this).remove();
});
}
});
}
});
</script>
答案 0 :(得分:0)
您可以尝试使用{ responseType: 'blob' }
作为选项。
要下载文件,您可以使用file-saver
import { saveAs } from 'file-saver';
this.http.get(url, { responseType: 'blob' }).subscribe((resp: any) => {
FileSaver.saveAs(resp, `abc.zip`);
})