title: Image/Media MIME type responses in Undertow
body: <p>I've been struggling trying to find a way to deliver .jpeg, .png or other contents in Undertow. Sending byte[] won't work and since Undertow is Non-blocking, I don't want to write the file on the output by doing the usual:</p>
  
  <pre><code>exchange.getOutputStream().write(myFileByteArray);
  </code></pre>
  
  <p>Is there any other way I can achieve it? I also encoded the image in Base64 using Undertow's default Base64 library, but didn't work either.</p>
  
  <p>Edit: providing some code:
  This is my method that encodes a file. It works for .js, .html and other text files, but not for images. The encoding is working, though, so my question is if I'm doing something wrong when sending it back to the person who requested.</p>
  
  <p>This how I'm responding: (hardcoded for stackoverflow purposes)</p>
  
  <pre><code>exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "image/jpeg");
  exchange.getResponseSender().send(getResource(resource, true));
  </code></pre>
  
  <p><strong>I'm not getting any exception on the undertow side. Image just won't show up on the browser. The browser says it can't decode the image..</strong></p>
  
  <p>Thanks.</p>