[prev in list] [next in list] [prev in thread] [next in thread] 

List:       esb-java-dev
Subject:    Re: [Dev] Placing file according to File pattern WSO2
From:       Shakila Sasikaran <shakila () wso2 ! com>
Date:       2018-10-19 4:39:48
Message-ID: CAJTQ=OYe-NL56rYRFOejDpqzwr4TV_HxyuXGZXLmof4_A75Piw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 <amansingh0624@gmail.com> 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
shakila@wso2.com
WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div dir="ltr">Hi Aman,<div><br></div><div>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.  </div><div>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.</div><div><br></div><div>[1] <a \
href="https://docs.wso2.com/display/EI640/File+Inbound+Protocol">https://docs.wso2.com/display/EI640/File+Inbound+Protocol</a></div><div>[2]&lt;property \
name=&quot;fileName&quot; expression=&quot;$trp:FILE_NAME&quot; \
scope=&quot;default&quot; \
type=&quot;STRING&quot;/&gt;<br></div><div><br></div><div>Thanks<br></div></div></div></div></div></div></div></div></div><br><div \
class="gmail_quote"><div dir="ltr">On Tue, Oct 16, 2018 at 9:52 AM Aman Singh &lt;<a \
href="mailto:amansingh0624@gmail.com">amansingh0624@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Dear \
Shakila,<div><br></div><div>Can you please help me with a logic I am struck with.  \
</div><div>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.</div><div>Suppose if file name is \
&#39;Student001.xml&#39;, then that file should be moved to folder named 001. If the \
file name is &#39;Student002.xml&#39;, then that file should be moved to folder named \
001 in my local.</div><div><br></div><div>My proxy code to copy file is \
below:-</div><div><br></div><div><div>&lt;proxy name=&quot;SFTPFileProxy2&quot; \
startOnLoad=&quot;true&quot; transports=&quot;http https&quot; xmlns=&quot;<a \
href="http://ws.apache.org/ns/synapse" \
target="_blank">http://ws.apache.org/ns/synapse</a>&quot;&gt;</div><div>      \
&lt;target&gt;</div><div>            &lt;inSequence&gt;</div><div>                  \
&lt;fileconnector.copy&gt;</div><div>                        \
&lt;source&gt;sftp://UserName:Password@hostname/home/ContainingFolder/&lt;/source&gt;</div><div> \
&lt;destination&gt;file:///D:/ESBFileProcessingSFTPOutput/AfterProcess/&lt;/destination&gt;</div><div> \
&lt;filePattern&gt;.*.*&lt;/filePattern&gt;</div><div>                        \
&lt;setTimeout&gt;100000&lt;/setTimeout&gt;</div><div>                        \
&lt;setPassiveMode&gt;true&lt;/setPassiveMode&gt;</div><div>                        \
&lt;setSoTimeout&gt;100000&lt;/setSoTimeout&gt;</div><div>                  \
&lt;/fileconnector.copy&gt;</div><div>            &lt;/inSequence&gt;</div><div>      \
&lt;outSequence&gt;</div><div>                  &lt;respond/&gt;</div><div>           \
&lt;/outSequence&gt;</div><div>            &lt;faultSequence/&gt;</div><div>      \
&lt;/target&gt;</div><div>&lt;/proxy&gt;</div></div><div><br></div><div>Can you help \
me with this logic?</div><div><br></div><div>Thank \
you,</div><div>Aman.</div></div></div> </blockquote></div><br \
clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" \
data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div \
dir="ltr"><span><font color="#888888">Shakila Sasikaran</font><br><font \
color="#888888">Software Engineer</font><br><font color="#888888">Mobile :+94 (0) 77 \
526 6848</font><div style="color:rgb(136,136,136)"><a href="mailto:shakila@wso2.com" \
target="_blank">shakila@wso2.com</a></div><div style="color:rgb(136,136,136)"><span \
style="color:rgb(102,102,102);font-size:small">WSO2, Inc.  </span><br \
style="color:rgb(102,102,102);font-size:small"><span \
style="color:rgb(102,102,102);font-size:small">lean . enterprise . \
middleware</span><br></div><div><font color="#666666" size="2"><a \
href="http://www.wso2.com/" \
target="_blank">http://www.wso2.com/</a></font><br></div></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div>




_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic