[undertow-dev] Serving an Individual File

Stuart Douglas sdouglas at redhat.com
Mon Oct 17 00:59:22 EDT 2016


This should do it:

final FileChannel channel = FileChannel.open(file, StandardOpenOption.READ);
final Sender sender = exchange.getResponseSender();
sender.transferFrom(channel, new IoCallback() {
....
});

Note that this will not close the channel automatically, it must be
done in the callback.

Stuart



On Mon, Oct 17, 2016 at 3:54 AM, Hicks, Matt <matt at matthicks.com> wrote:
> The ResourceManager is great for serving directories, but if I have a very
> specific file I want to serve up is there any built-in functionality to
> conveniently do so?  I've looked through the documentation and the examples
> and can't seem to find any references to doing this.  Help would be greatly
> appreciated.
>
> Thanks
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev


More information about the undertow-dev mailing list