这是我的服务器端代码:
@GET
@Path("/{id}/photo")
@Produces(MediaType.MULTIPART_FORM_DATA)
public Response getPhoto(@PathParam("id") Long id){
String imgData = //raw content of file
return Response
.ok(imgData, MediaType.APPLICATION_OCTET_STREAM)
.header("content-disposition", "attachment; filename = testDownloadImage.png")
.build();
}
我想在浏览器上显示图片。客户端上的资源是:
return $resource('', null, {
getPhoto: {
method: 'GET',
url: baseURL + ':id/photo',
transformRequest: angular.identity,
headers: {'Content-Type': undefined},
isArray: false
}
})
并且
resoucre.getPhoto({id: ID}).$promise
.then(function (returnedPhoto) {
if (returnedPhoto != null) {
$scope.photo = returnedPhoto;
}
});
HTMl是
<img ng-src="data:image/png;base64,{{photo}}"/><br/>
但是图像没有显示,我有一些像这里的奇怪数据
GET data:image/png;base64,{"0":"i","1":"V","2":"B"...