Hi Aman,

In your use-case you want to move all files which are placed to a
particular location. Therefore you can use file inbound endpoint [1] to
poll the files from the source directory. And basically this will inject
the file to the configured sequence. So, inside that sequence you can get
the current file name with FILE_NAME property [2] and process it to find
the destination folder. Then build the destination path with the concat
function and finally invoke the copy/create method of file connector.
If you are going to use the copy method, you can use the FILE_URI and
FILE_NAME properties to determine the source instead of hardcoding the
source file path.

[1] https://docs.wso2.com/display/EI640/File+Inbound+Protocol
[2]<property name="fileName" expression="$trp:FILE_NAME" scope="default"
type="STRING"/>

Thanks

On Tue, Oct 16, 2018 at 9:52 AM Aman Singh <[email protected]> wrote:

> Dear Shakila,
>
> Can you please help me with a logic I am struck with.
> I am trying to copy a file from my server and storing it in local(say the
> file I copied is Student001.xml ). After that I want to move the file to
> specific folder according to file pattern.
> Suppose if file name is 'Student001.xml', then that file should be moved
> to folder named 001. If the file name is 'Student002.xml', then that file
> should be moved to folder named 001 in my local.
>
> My proxy code to copy file is below:-
>
> <proxy name="SFTPFileProxy2" startOnLoad="true" transports="http https"
> xmlns="http://ws.apache.org/ns/synapse";>
>     <target>
>         <inSequence>
>             <fileconnector.copy>
>                 <source>sftp://UserName:Password@hostname
> /home/ContainingFolder/</source>
>
> <destination>file:///D:/ESBFileProcessingSFTPOutput/AfterProcess/</destination>
>                 <filePattern>.*.*</filePattern>
>                 <setTimeout>100000</setTimeout>
>                 <setPassiveMode>true</setPassiveMode>
>                 <setSoTimeout>100000</setSoTimeout>
>             </fileconnector.copy>
>         </inSequence>
>         <outSequence>
>             <respond/>
>         </outSequence>
>         <faultSequence/>
>     </target>
> </proxy>
>
> Can you help me with this logic?
>
> Thank you,
> Aman.
>


-- 
Shakila Sasikaran
Software Engineer
Mobile :+94 (0) 77 526 6848
[email protected]
WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to