SFTP Function

SFTP stands for Secure file transfer protocol. In layman’s language it is a highly secured place for storing files. Initially there was only FTP (File transfer protocol), but these FTPs were vulnerable to getting hacked so FTPS (File transfer protocol secured) was introduced and after this SFTP was introduced. The difference between SFTP and FTPS is that FTPS uses just 1 layer of security where SFTP uses advanced and multilayers of security.

Note:

For downloading and uploading files in SFTP, an ftpconnections.config file should be present in the Runner folder of the server. This file contains all the credentials required to login in the SFTP. After placing the file, we have to add a SFTP/FTP connection in the configeditor.exe and test the connection if the connection is successful you are ready to use the SFTP.

There are 3 functions in SFTP:

The 1st function i.e. ftplistDirectory.sk will give you the list of files which are present in the sftp.

The 2nd function i.e. ftpdownload.sk will download the file.

The 3rd function i.e. ftpupload.sk will upload the file.

Steps to download files from sftp:

1. For getting files from SFTP first we need to write the details of the sftp.

The details of the SFTP consists of Name of the SFTP and folder of the SFTP where the required files are stored.

2. Now these details will be given as arguments to the ftplistdirectory.sk function so that the function can give the path of the files present in the sftp.

The picture below shows the Fx of ftplistdirectory.sk.

  • In this the 1st argument of the function is the Connection name i.e. the name of the SFTP.

  • The 2nd argument of the function is the Directory Path i.e. the name of the folder in the SFTP in which the files are stored.

  • The 3rd argument of the function is File Name/Pattern. It can be “.” or if you want to give a particular file format like .xlsx or .csv you can give that as well.

  • The 4th argument of the function is Recursive which can be either TRUE or FALSE. Recursive is whether you want to get the list of files from the subfolder also or only from the folder mentioned in the 2nd argument onl. It will be TRUE if you want to get the list of files from the subfolders also or else it will FALSE.

  • The 5th argument of the function is File Parameter 1 which is FULL PATH. It will give the file path of the file.

  • The 6th argument of the function is File Parameter 2 which is FILE NAME. This argument of the function is optional if you want the file name you can give it or else close function.

  • The output of this function will be list of all the files present in the directory and if you have passed FULL NAME as the second parameter then the output will also have file names also.

3. After you get the list of files you want to download we have to use ftpdownload.sk to download the files.

Kindly Note that the arguments of ftpupload.sk and ftpdownload are same.

The Fx of ftpdowload.sk is as shown in the picture below.

  • The 1st argument of the function is Connection Name which same as the ftplistdirectory.sk.

  • The 2nd argument of the function is Source Path which will the output of the Ftplistdirectory.sk

  • The 3rd argument of the function is destination folder. This argument is optional, if you want the file to be downloaded in desired folder then you have to give the file path in this argument or else close the function. If you don’t want to give the file path it will be downloaded in a temporary path.