File to Byte Array in Mule
File to Byte Array transformer reads the input file and converts the content into byte array.
flow of File to Byte Array transformer :
Input text file should be in src/main/resources.
We not need to configure anything in File to Byte Array transformer.
Logger is configured with #[payload]
Logger output :
there we can see output is in byte array format.
XML project code :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<file:connector name="File" outputPattern="file.txt" readFromDirectory="src/main/resources/input" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="test_filetobytearrayFlow">
<file:inbound-endpoint path="src/main/resources/input" connector-ref="File" pollingFrequency="10000" responseTimeout="10000" doc:name="File"/>
<file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
No comments:
Post a Comment