title: AngularJS show image from byte array sent in response
body: <p>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</p>
  
  <blockquote>
    <p>�PNG</p>
  </blockquote>
  
  <p>IHDR&amp;��LCv�IDATx��......</p>
  
  <p>What would be best solution to solve this maybe i should change response type is it possible to send not bytes?</p>
  
  <pre><code>@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);
  }
  </code></pre>
  
  <p>Js code </p>
  
  <pre><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);
      });
  };
  </code></pre>
  
  <p>Html code </p>
  
  <pre><code>&lt;img class="thumb image-properties" ng-if="image" ng-src="{{image}}" /&gt;
  </code></pre>