Transferring files with vfs and file-connector in WSO2 ESB

Here I will be discussing on how to transfer a set of files defined in a document, to another location using a proxy in WSO2 ESB 4.8.1. Suppose the names of the files are defined in the file-names.xml file. Suppose the file has the following xml structure.
    <files-set name="files-set-1">
        <file name="img1">image1.png</file>
        <file name="img2">image2.png</file>
    <files-set name="files-set-2">
        <file name="img3">image6.png</file>
        <file name="img4">image4.png</file>
 <file name="img5">image5.png</file>
The procedure i'm going to follow is, read the file names defined in the file-names.xml using vfs, and transfer the files using the file connector. First we need to enable the vfs in the proxy. Please refer [1] on how to enable vfs transport to a proxy. Once vfs is enabled, the proxy should look like follows.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="" name="FileProxy" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
   <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
   <parameter name="transport.PollInterval">15</parameter>
   <parameter name="transport.vfs.MoveAfterProcess">file:///some/path/success/</parameter>
   <parameter name="transport.vfs.FileURI">file:///some/path/in/</parameter>
   <parameter name="transport.vfs.MoveAfterFailure">file:///some/path/failure</parameter>
   <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
   <parameter name="transport.vfs.ContentType">application/xml</parameter>
   <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
   <description />

Here "FileURI" is the directory location of the file-names.xml. "MoveAfterProcess" is the directory where the file-names.xml should be moved after successfully reading. "MoveAfterFailure" is the location where the file-names.xml file should be moved if some failure occurs during reading it.
Now we need to extract the file names defined in this file-names.xml. For that i'm going to iterate through the file names using iterator mediator [2].
 <iterate preservePayload="true" attachPath="//files/files-set" expression="//files/files-set/file"
   <property name="image" expression="//files/files-set/file"/>
Finally, move the files using the file-connector[3] , as follows.
   <property name="fileName" expression="//files/files-set/file"/>
   <property name="fileLocation" value="ftp://some/path/in/"/>
   <property name="newFileLocation" value="ftp://some/path/success/"/>
Here, "fileLocation" refers to the directory in which the files we need to move are located, and "newFileLocation" refers to the directory to which the files should be moved. You can use either a localfile system location as well as ftp location for both these properties.





  1. Hi,

    In WSO2 ESB, how do you transfer file from one ftp location to another without reading file content?

    Thank you,
    M. Tai

  2. One year later, Same day... and I try to find this answer ^^. A.DJELASSI