How to get multiple files from the SFTP server


One of my Flow logics required to extract multiple files from the SFTP server. But we have only SFTP get built in service. Kindly help me how to mget the files from the SFTP server.

Thanks in advance, Manjunath

Unfortunately you do not have built in service for mput and mget in sftp. But you have the same in ftp.

For your requirement you can do something below;

1> get the list of the file names from the sftp directory (output will be stringList)
2> Use a loop and call the pub.client.sftp:get

Or if you are java expert you may write a java code using JSCH API (eg: jsch-0.1.37)

I hope SAG adds the mget and mput services for SFTP just like FTP in the next release. :slight_smile: :slight_smile:

1 Like

Or Try using OpenSSH package available in code samples on SAG tech community.

Hi Mahesh,

Thanks for your reply !!.

We can use the existing pub.client.sftp:get service for both get as well as mget function .

How did you achieve it? Can you share the pseudo code?

Input Parameters::

sessionKey : Session Key of the SFTP server.
remoteFile : * ( All files of the current directory )
localFile : Archive location

Yep! your input parameters make sense :slight_smile: Thanks for your update.