I am trying to allow my game client to download the cache needed for the client to run. Inside of my game web server I am doing this:
@RouteManifest(template="/cache", method="GET")
public class APICacheRoute extends RouteHttpHandler<JadePreprocessor> {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
Path path = Paths.get("./cache/Alterscape.zip");
File file = path.toFile();
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream");
exchange.getResponseSender().send(file);
}
}
However, I am receiving the error that the file must be a ByteBuffer. How can I return a file to download?
My web server looks like this:
public static void initialize() {
ServerController server = new ServerController("localhost", 8080, 8443);
server.register(new APIVirtualHost());
server.inititialize();
}
My APIVirtualHost looks like this:
public APIVirtualHost() {
super(127.0.0.1);
setDirectoryListingEnabled(false);
}