Skip to main content
enam
Silver ⭐️⭐️⭐️
January 11, 2024
Solved

Read files from SFTP server and put file in back using sftp in apache NIFI

Dear Sir,

I am using apache nifi for

  1.  Getting file from SFTP server
  2. Backup files another SFTP server
  3. Delete the  all files from where getting locations
  4. process file to call invokeHttp Request

SFTP images using winscp:

enam_1-1704967317885.jpeg

After login folder locations:

enam_2-1704967343052.jpeg

 

 

1. Here is the diagram:

enam_0-1704967223172.jpeg

2. ListSFTP properties:

enam_3-1704967437864.jpeg

3. FetchSFTP properties

enam_4-1704967463103.jpeg

3. Put SFTP properties

enam_5-1704967480448.jpeg

I follow processors  bellow sequences: 

ListSFTP--> FetchSFTP-->PutSFTP-->UpdateAttribute --> InvokeHttp

I did not get file from sftp server. 

What is the wrong of my configuration?

 

 

 

MattWho
MattWhoAnswer
Titanium ⭐️⭐️⭐️
January 11, 2024

@enam 

Looks like you have a bad file filter regex in your listSFTP processor configuration.

.*file.*\.xls

Above looks for any character for 1 or more characters until is finds the last occurrence of string "file" followed by any character for as many characters until last occurrence of string ".xls".  However, all your filenames start with "file" and have no characters before it.

Try modifying your file filter regex by removing the ".*" before "file":

file.*\.xls

 Right click on processor, select "view state", and then "clear state".  Then start the listSFTP processor again to see if generated NiFi FlowFiles for each file on your SFTP server.

If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

2 replies

Elnozy
Silver ⭐️⭐️
January 11, 2024

@enam, have you check the state of the ListSFTP processor (action "view State")?

With the listing strategy equals "Tracking timestamp", the processor save the last time it checks the SFTP folder and don't retrieve older files than this timestamp.

Translate
MattWho
Titanium ⭐️⭐️⭐️
MattWhoAnswer
Titanium ⭐️⭐️⭐️
January 11, 2024

@enam 

Looks like you have a bad file filter regex in your listSFTP processor configuration.

.*file.*\.xls

Above looks for any character for 1 or more characters until is finds the last occurrence of string "file" followed by any character for as many characters until last occurrence of string ".xls".  However, all your filenames start with "file" and have no characters before it.

Try modifying your file filter regex by removing the ".*" before "file":

file.*\.xls

 Right click on processor, select "view state", and then "clear state".  Then start the listSFTP processor again to see if generated NiFi FlowFiles for each file on your SFTP server.

If you found any of the suggestions/solutions provided helped you with your issue, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

Translate