I have a service which adds some properties to file and sends it back in a response as byte array, but i have hard time displaying it as it is bytes, i tried to convert it to base64 but it still didn't worked. It shows raw bytes
�PNG
IHDR&��LCv�IDATx��......
What would be best solution to solve this maybe i should change response type is it possible to send not bytes?
@RequestMapping(path = "image/decode", method = POST, consumes = "multipart/form-data", produces = {"image/png", "image/jpeg"})
public byte[] decodeImage(@RequestParam("file") MultipartFile file) throws Exception {
File file1 = addProperties(file);
return FileUtils.readFileToByteArray(file1);
}
Js code
$scope.extractImage = function (sourceFile) {
Upload.upload({
url: '/image/decode',
objectKey: '',
data: {
file: sourceFile
}
}).then(function (response) {
console.log('Success ' +'Response: ' + response);
$scope.image = response.data;
}, function (response) {
console.log('Error status: ' + response);
});
};
Html code
<img class="thumb image-properties" ng-if="image" ng-src="{{image}}" />