ScArcher2
ScArcher2

Reputation: 87187

How do I write out a file using camel, and return the name of the file?

If I send direct:report a byte[]. How do I find out the absolute path and name of the file it was written to?

from("direct:report").to("file:target/reports");

Upvotes: 1

Views: 2791

Answers (2)

Ben ODay
Ben ODay

Reputation: 21005

Use the "fileName" attribute to set the name explicitly. The path is relative to your container (junit, servicemix, etc)...so the full path to your file would be [container-root]/target/reports/[fileName]

Upvotes: 0

Claus Ibsen
Claus Ibsen

Reputation: 55525

The file producer will add an header with the key CamelFileNameProduced which contains the actual name of the file written.

The actual absolute filepath (path + name) for the output file that was written. This header is set by Camel and its purpose is providing end-users with the name of the file that was written.

Upvotes: 5

Related Questions