Share:
Developers » Script Objects & Methods » ScriptFtpClient

PREVIOUS  |  NEXT

ScriptFtpClient


Define the following FTP server parameters to use FTP in scripting:

Parameter name Default Value Explanation
serverIP address of the FTP server
usernameUser name used to connect to FTP
passwordPassword used to connect to FTP
port21Port on which your FTP is working
protocolFTPProtocol on which your FTP is working
encryptionSSLEncryption which you will be using
modePASSIVEValue can be PASSIVE or ACTIVE
isImplicitfalseValue can be false or true


The parameters are placed on a map and then you can connect to FTP server with the following method:

resp.ftpConnect(params)

You can also add them as custom parameters in the Custom Parameters tab in Setup > System Settings > Organization Settings and then connect to the FTP server with the following method:

resp.ftpConnect("ftp.gw");


The following methods are available for FTP in scripting:

Return Type Method Explanation
ScriptFiledownload(String dir, String fileName)Downloads a file from a remote directory using FTP
ScriptFileupload(ScriptFile file, String dir, String fileName, boolean overwrite, boolean createDirectories)

For this method:

  • Uploads a file to a remote directory
  • If specified, the file name will override the source file name
  • Behavior can be configured using overwrite and createDirectories parameters
  • Returns uploaded file if the upload is successful; otherwise returns null 
ScriptFileupload(ScriptFile file, String dir, String fileName)

For this method:

  • Uploads a file to a remote directory
  • If specified, the file name will override the source file name
  • This method will not overwrite a file, or create directories if they don't already exist
  • Returns the uploaded file if the upload is successful; otherwise returns null
ScriptFileupload(String content, String encoding, String dir, String fileName, boolean overwrite, boolean createDirectories)

For this method:

  • Uploads a file with given content to a remote directory
  • If encoding is not specified, UTF-8 will be used as default
  • Can overwrite an existing file with the same name
  • Can create one or more directories if they don't exist, when specified by the parameters
ScriptFileupload(String content, String encoding, String dir, String fileName)

For this method:

  • Uploads a file with given content to a remote directory
  • This method will not overwrite a file or create directories if they don't already exist
 VoidftpConnect(String parameter);

For this method:

  • Connects to FTP server using parameters defined in Custom Parameters
  • Example: This parameter can be "ftp.gw" from the example above this table
VoidftpConnect(Map params);

For this method:

  • Connects to the FTP server using the Map in which you defined the parameters
  • If you haven't defined parameters for those that have existing default values, the default value will be used
Listlist(String dir)

For this method:

  • Returns a list of strings with the names of files and folders in a given folder
  • Example for dir: "/home/user/ftp_test"