我在我的打字稿中有下面的代码来调用web api方法并检索一个PDF的二进制字节数组(blob).我的用户要求是在新窗口中打开PDF.
$scope.selectRow = (itemImageNumber: string, printProcessId: string, printXmlId: string) => { itemService.GetOutgoingDocument($scope.item.ItemId, itemImageNumber, printProcessId, printXmlId).success((response) => { var file = new Blob([response], { type: 'application/pdf' }); var fileUrl = URL.createObjectURL(file); //$scope.outDocContent = $sce.trustAsResourceUrl(fileUrl); var win = window.open($sce.trustAsResourceUrl(fileUrl)); win.focus(); }).error(() => { var message = "The document you selected can’t be displayed at this time. Please call Customer Service at xxx-xxx-xxxx for assistance."; $rootScope.$broadcast("app-message", { type : "danger", message : message }); }); }
此代码在Chrome中运行良好.该文件按预期打开.然而,IE问"你想让这个网站在你的电脑上打开一个应用程序吗?" 如果允许,请告诉我"没有安装应用程序来打开这种链接(blob)".
有关如何在新选项卡中打开它或将blob保存为文件作为最后手段的任何想法?