How to specify the relative path for the File inbound connector in Mule

1.9k views Asked by At

I am using the file inbound connector in Mule 3.8.1 to read a file from a directory on my computer.

I want to reference the file using the relative path but it looks like I cannot get the syntax right as the file stays there unprocessed.

When I use the absolute path it picks the file up.

Can anyone see what I am doing wrong?

<?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">
    <flow name="test.xmlFlow">
        <file:inbound-endpoint path="src/main/resources/input/stores" responseTimeout="10000" doc:name="File">
            <file:filename-regex-filter pattern="(.*).csv" caseSensitive="true"/>
        </file:inbound-endpoint>
        <logger level="INFO" doc:name="Logger"/>
    </flow>
</mule>

Thanks

1

There are 1 answers

0
Anirban Sen Chowdhary On

Try to add <file:file-to-string-transformer doc:name="File to String"/> after <file:inbound-endpoint/>
This works fine for me :-

  <flow name="test.xmlFlow">
    <file:inbound-endpoint path="src/main/resources/input/stores" responseTimeout="10000" doc:name="File">
        <file:filename-regex-filter pattern="(.*).csv"
            caseSensitive="true" />
    </file:inbound-endpoint>
    <file:file-to-string-transformer doc:name="File to String" />
    <logger level="INFO" doc:name="Logger" />
</flow>