Reputation: 2705
I have written a controller in spring boot for getting image of particular user and i am returning it in form of byte array
@GetMapping(value = "/images/{id}/{login}",produces = {MediaType.APPLICATION_OCTET_STREAM_VALUE})
public byte[] getImage(@Valid @RequestParam("id") String id,@RequestParam("login") String login)
throws IOException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, InvalidArgumentException, ErrorResponseException, NoResponseException, InvalidBucketNameException, InsufficientDataException, InternalException {
return IOUtils.toByteArray(fileService.getImage(id, login));
}
Is there a method in angularjs so that i could convert it in form of image So that i could display the profile Picture of User
Upvotes: 0
Views: 1115
Reputation: 467
in angularjs you add function
vm.getByte = function(){
$http({
method: 'GET',
url: '/images/{id}/{login}'
}).success(function(success){
vm.imgFile = success;
});
};
to get byte array
and in html
<img ng-src="data:image/JPEG;base64,{{vm.imgFile}}" style="width: 200px;height: 130px;" />
Upvotes: 2