<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 </head><body><p>Hello,<br></p><p><br></p><p>I am experimenting with undertow and from the examples I cannot find a way to send files from my own HttpHandler. I would like to use some async way of doing this because in my use case my handler is already in the middle of some processing using only async code.<br></p><p>RandomAccessFile aFile = new RandomAccessFile(&#34;readfile.txt&#34;, &#8220;r&#8221;);</p><p>FileChannel inChannel = aFile.getChannel();</p><p>exchange.getResponseChannel().transferFrom(channel, 0, 0);<br></p><p><br></p><p>This would be blocking code right? so it is not desired to be done in the IO Thread.<br></p><p>How could i do this with an async channel?<br></p><p>String filePath = &#34;readfile.txt&#34;;<br></p><p>Path path = Paths.get(filePath);<br>AsynchronousFileChannel channel = AsynchronousFileChannel.open(path, StandardOpenOption.READ);</p><p><br></p><p>Now i would like to send it over the HTTP stream to the client, what would be the best way using undertow?<br></p><p>Or is my idea totally wrong and i should not do this?<br></p></body></html>