...
The Zip File Data Format is a message compression and de-compression format. Messages can be marshalled (compressed) to Zip files containing a single entry, and Zip files containing a single entry can be unmarshalled (decompressed) to the original file contents. This data format supports ZIP64, as long as Java 7 or later is being used.
Since Camel 2.1312.3 there is also a aggregation strategy that can aggregate multiple messages into a single Zip file.
...
Info |
---|
Please note that this aggregation strategy requires eager completion check to work properly. |
In this example we aggregate all text files found in the input directory into a singel single Zip file that is stored in the output directory.
Code Block |
---|
from("file:input/directory?antInclude=*/.txt") .aggregate(new ZipAggregationStrategy()) .constant(true) .completionFromBatchConsumer() .eagerCheckCompletion() .to("file:output/directory"); |
...
Code Block |
---|
from("file:input/directory?antInclude=*/.txt") .aggregate(new ZipAggregationStrategy()) .constant(true) .completionFromBatchConsumer() .eagerCheckCompletion() .setHeader(Exchange.FILE_NAME, constant("reports.zip")) .to("file:output/directory"); |
Dependencies
To use Zip files in your camel routes you need to add a dependency on camel-zipfile which implements this data format.
...