I'm trying to zip a folder with Camel. I have a Processor
that hass created folders with files inside them:
public class CreateDirProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
File d = new File("myDir/hi");
d.mkdirs();
File f = new File(d, "hello.txt");
f.createNewFile();
in.setBody(f);
}
}
It works correctly.
In my route, I try to zip the hi
folder so I did this:
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
ProducerTemplate template = context.createProducerTemplate();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:source")
.process(new CreateDirProcessor())
.marshal().zipFile().to("file:zipped");
}
});
context.start();
template.sendBody("direct:source", "test");
Thread.sleep(3000);
context.stop();
}
And that does not work. I got:
TypeConversionException: Error during type conversion from type: java.io.File to the required type... `myDir/hi` is a directory
Is a directory not a file? Is it not possible to zip a whole folder and its contents with Camel?
Thank you all.