AngularJS/S3-将arrayBuffer转换为blob“;未能加载PDF文档";
我已经找了几个小时试图找到解决这个问题的办法 我在我的node和express应用程序中点击了一个端点,并返回了一个arraybuffer,但是当我尝试查看blob时,我得到了错误“加载PDF文档失败” 这是我的发球AngularJS/S3-将arrayBuffer转换为blob“;未能加载PDF文档";,angularjs,pdf,amazon-s3,Angularjs,Pdf,Amazon S3,我已经找了几个小时试图找到解决这个问题的办法 我在我的node和express应用程序中点击了一个端点,并返回了一个arraybuffer,但是当我尝试查看blob时,我得到了错误“加载PDF文档失败” 这是我的发球 app.service('aws', function($http, $q) { this.getObject = function(file_name){ return $q.when($http.get(api + 'aws/getObject?file_name
app.service('aws', function($http, $q) {
this.getObject = function(file_name){
return $q.when($http.get(api + 'aws/getObject?file_name=' + file_name, {responseType: 'arraybuffer'}))
}
})
然后让我去欣赏它
aws.getObject(filename).then(function(response){
var blob = new Blob([response.data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(blob);
$scope.document = $sce.trustAsResourceUrl(fileURL)
})
我甚至试着用这个反应
aws.getObject(filename).then(function(response){
var blob = new Blob([response], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(blob);
$scope.document = $sce.trustAsResourceUrl(fileURL)
})
然后在这里显示
<object data="{{document}}" type="application/pdf" style="width:100%; height:400px" />
但无论我尝试了什么,它仍然返回“未能加载PDF文档”提供有关错误的更多详细信息,并尝试控制台response.data和response,检查哪一个将正确打印数据。提供有关错误的更多详细信息,并尝试控制台response.data和response,检查哪一个将正确打印数据。