Skip to main content

Hi,

 

I am trying to list zip files in an FTP location and unzip it. It is working fine with File list and not with FTP list. Please help me on this.

 

Below is my code using zip extensions in FTP. I am listing all the zips files and it is working fine for File list but not for FTP list. in File pattern i have give as *.zip also . Below is my code. Please help me on this

 

<?xml version="1.0" encoding="UTF-8"?>

 

<mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp"

xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:compression="http://www.mulesoft.org/schema/mule/compression"

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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="

http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/compression http://www.mulesoft.org/schema/mule/compression/current/mule-compression.xsd

http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd

http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd">

 

<file:config name="File_Config1" doc:name="File Config" doc:id="5370704c-51c3-4ec4-85ce-ef626e31432c" >

<file:connection workingDir="C:\Users\Srikanth.S\Documents\ProjectWork\Recordati\Unzips"/>

</file:config>

<file:config name="File_Config" doc:name="File Config" doc:id="1d1c6349-065a-47e2-9215-3f6f9c479b0e" >

<file:connection/>

</file:config>

<file:config name="File_Copy_Config" doc:name="File Config" doc:id="a6bb55e8-a14d-4c66-866f-c2db2ba8b6a7" />

<configuration-properties doc:name="Configuration properties" doc:id="5ffb2862-6f6b-45fd-ab24-18a444b8bd33" file="mule-app.properties" />

<ftp:config name="FTP_Config" doc:name="FTP Config" doc:id="7dc1248f-7b52-44f8-97ba-a29f43ba7402" >

<ftp:connection host="${ftp.host}" username="${ftp.user}" password="${ftp.pass}" />

</ftp:config>

<flow name="archive-extract-test" >

<file:list doc:name="List" doc:id="ab15b542-d086-49b9-83f6-5ae55b82aa00" config-ref="File_Copy_Config" directoryPath="C:\Users\Srikanth.S\Documents\ProjectWork\Recordati\Unzips\lists\">

<file:matcher filenamePattern="*.zip"/>

</file:list>

<foreach doc:name="For Each" doc:id="0abb4d26-5e74-4532-9713-9acbec2318aa" collection="payload">

<compression:extract doc:name="Extract" doc:id="90a2d174-ccaf-4264-bd81-49f1ab4a70a9">

<compression:extractor>

<compression:zip-extractor />

</compression:extractor>

</compression:extract>

<foreach doc:name="For Each" collection="payload">

 <file:write doc:name="Write" doc:id="0cfc3cd7-c444-432a-a0ea-6891f0f78c74" config-ref="File_Config1" path='#[output application/json

 

---

 

"output/" ++ (payload pluck $$)[0]]'>

<file:content><![CDATA[#output application/java --- ( payload pluck $)[0]]]></file:content>

</file:write>

</foreach>

</foreach>

 </flow>

<flow name="unzipfilestestFlow1" doc:id="fb2d2072-6446-42b2-900c-17cec597999d" >

<scheduler doc:name="Scheduler">

<scheduling-strategy>

<fixed-frequency frequency="15" timeUnit="SECONDS" />

</scheduling-strategy>

</scheduler>

<ftp:list doc:id="c90bfab4-7dcd-4a37-a67b-59b9b7f9375f" config-ref="FTP_Config" directoryPath="/Srikanth/FTPUnzips">

<ftp:matcher filenamePattern='"T7RecordDE_DEOTC_?*.zip"' />

</ftp:list>

<foreach doc:name="For Each" doc:id="50372e45-1488-46bf-838f-71acf015b0d5" collection="payload">

<compression:extract doc:name="Extract" doc:id="3fbfafd3-ee81-49c6-be66-6d7c9cc6d6d8" >

<compression:extractor >

<compression:zip-extractor />

</compression:extractor>

</compression:extract>

<foreach doc:name="For Each" doc:id="c117dbea-101d-4f93-8f2d-c55bffc04c38" >

<ftp:write doc:name="Write" doc:id="b91e2226-b0f1-4441-81bc-756e50b75336" config-ref="FTP_Config" path='#[output application/json

 

---

 

"output/" ++ (payload pluck $$)[0]]'>

<ftp:content ><![CDATA[#output application/java --- ( payload pluck $)[0]]]></ftp:content>

</ftp:write>

</foreach>

</foreach>

</flow>

 

</mule>

1 answer
  1. Jul 14, 2020, 8:59 AM

    It could be you are encountering case sensitivity on the remote file system vs your local windows machine which doesn't care? I'd try some tests doing lists with quite broad pattern to see what's going on. Also check if that question mark is being treated as a regex or not..

     

    Also: strongly recommend NOT using FTP as a protocol - it's missing the important "S" part (aka security).

0/9000