You can use a combination of Camel REST DSL and Content Enricher (specifically - pollEnrich
).
An example implementation for your case could look like this:
// you can configure it as you want, it's just an example
restConfiguration().component("restlet").host("localhost").port(8081);
rest("/jar")
.get()
.produces(MediaType.APPLICATION_OCTET_STREAM_VALUE)
.route()
.routeId("downloadFile")
.pollEnrich("file:/home/user/Downloads?fileName=classes.jar&noop=true")
.setHeader("Content-Disposition", simple("attachment;filename=classes.jar"));
Please note, that if the file is not found in the specified path, pollEnrich
will block until the file arrives. You can set a timeout in milliseconds by providing a second argument of type long
to the call to pollEnrich
.