Hello,
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.
RandomAccessFile aFile = new RandomAccessFile("readfile.txt", “r”);
FileChannel inChannel = aFile.getChannel();
exchange.getResponseChannel().transferFrom(channel, 0, 0);
This would be blocking code right? so it is not desired to be done in the IO Thread.
How could i do this with an async channel?
String filePath = "readfile.txt";
Path path = Paths.get(filePath);
AsynchronousFileChannel channel = AsynchronousFileChannel.open(path, StandardOpenOption.READ);
Now i would like to send it over the HTTP stream to the client, what would be the best way using undertow?
Or is my idea totally wrong and i should not do this?