title: spring - returning files in a response object
body: <p>I'm trying to return an image as a response in spring framework,
  it works just fine implementing like this:</p>
  
  <pre><code>@GetMapping(value = "/{photo}.{suf}")
  public @ResponseBody byte[] getImage(@PathVariable("photo") String photo,@PathVariable("suf") String suf) throws IOException{
      InputStream in = FileUtils.openInputStream(new File("src/main/resources/static/" + photo + "." +suf));
      return IOUtils.toByteArray(in);
  }
  </code></pre>
  
  <p>but when I try to return the image file inside a response object ,I get an org.springframework.web.HttpMediaTypeNotAcceptableException exception:</p>
  
  <pre><code>@GetMapping(value = "/{photo}.{suf}")
  public @ResponseBody ResponseObject getImage(@PathVariable("photo") String photo,@PathVariable("suf") String suf) throws IOException{
      InputStream in = FileUtils.openInputStream(new File("src/main/resources/static/" + photo + "." +suf));
      return new ResponseObject(IOUtils.toByteArray(in),1);
  }
  </code></pre>
  
  <p>here is my ResponseObject implementation:</p>
  
  <pre><code>public class ResponseObject {
  private Object object;
  private int status;
  public ResponseObject(Object object,int status){
      this.object = object;
      this.status = status;
  }
  public Object getObject() {
      return this.object;
  }
  
  public void setObject(Object object) {
      this.object = object;
  }
  
  public int getStatus() {
      return status;
  }
  
  public void setStatus(int status) {
      this.status = status;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Does anyone have any idea why this is happening?</p>