I have a <file:inbound-endpoint>
which reads a large file and pass it to a java component which splits large file into multiple smaller files. I add all these smaller files into a list and return list
from java component into mule flow.
Now, in mule flow, I am using <collection-splitter>
or <foreach>
to output those files to the <file:outbound-endpoint>
.
The problem is that
file:file-to-byte-array-transformer
after you've split the List<File>
and before file:outbound-endpoint
so Mule will read the actual content of the java.io.File
. outputPattern
on the file:outbound-endpoint
, using a MEL expression to construct a unique file name based on the properties of the in-flight message and also on other expressions, like timestamp or a UUID, whatever fits your needs. or 1st I did as @David suggested to add file:file-to-byte-array-transformer
.
For 2nd part, to get the name of file outputting to <file:outbound-endpoint>
same as the file name assigned while creating file, I did following:
<foreach>
<set-variable variableName="fname" value="#[payload.path]"/>
<logger level="INFO" message="fname is: #[fname]" />
<file:file-to-byte-array-transformer />
<file:outbound-endpoint path="${file.csv.path}" outputPattern="#[fname]"/>
</foreach>
Before converting file to byte array, get the file name as after byte array conversion, its not available in #[payload]
though you may still get it from #[originalPayload]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.