publish
plugins.it2be_ftp.SFTPclient info


Servoy Properties Summary
String host
Boolean isConnected
String password
Number port
String userName


Servoy Methods Summary
void cd( String )
void chmod( Number, String )
Boolean connect( )
Boolean disconnect( )
void get( String, String )
String getWorkingPath( SFTPsettings )
Array<Object> list( )
Array<SFTPfile> list( String )
void mkdir( String )
void mkdirs( String )
void mv( String, String )
void put( String, String )
void rm( String, Boolean, Boolean )
void rm( String )


Servoy Properties Details


host
String  host
Get/Set the host name.
Returns
String  host String

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


isConnected
Boolean  isConnected
Check that there is a connection.
Returns
Boolean  result boolean

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


password
String  password
Get/Set the password.
Returns
String  password String

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


port
Number  port
Get/Set the port.
Returns
Number  port int

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


userName
String  userName
Get/Set the userName.
Returns
String  username String

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}

Servoy Methods Details


cd
void  cd( String )
Change to another directory.
Parameters
String  path  the path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


chmod
void  chmod( Number, String )
Changes the access permissions or modes of the specified file or directory.
Parameters
Number  permissions  the permissions
String  path  the path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


connect
Boolean  connect( )
'Build' the connection (Don't forget to disconnect).
Returns
Boolean  result boolean

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


disconnect
Boolean  disconnect( )
Disconnect from the connection.
Returns
Boolean  result boolean

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


get
void  get( String, String )
Get a file.
Parameters
String  remotePath  the remote path
String  localPath  the local path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Get a file.
// retrieve a document from the server and write it under the designated name
// the first entry is the remote file
// the second entry is the local (new) file name
client.get("remoteFile", "localFile");


getWorkingPath
String  getWorkingPath( SFTPsettings )
Returns the absolute path name of the current remote working directory.
Parameters
SFTPsettings  settings  the settigns

Returns
String  path String

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


list
Array<Object>  list( )
List the contents of a remote directory.
Returns
Array<Object>  list Object[]

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


list
Array<SFTPfile>  list( String )
List the contents of a remote directory.
Parameters
String  path  the path

Returns
Array<SFTPfile>  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


mkdir
void  mkdir( String )
Creates a directory.
Parameters
String  path  the path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


mkdirs
void  mkdirs( String )
Creates a dir and any non-existing parent directories.
Parameters
String  path  the path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


mv
void  mv( String, String )
Rename a file on the remote computer.
Parameters
String  oldName  the old name
String  newName  the new name

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


put
void  put( String, String )
Put a file.
Parameters
String  localPath  the local path
String  remotePath  the remote path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Put a file.
// send a document to the server and write it under the designated name
// the first entry is the local file
// the second entry is the remote (new) file name
client.put("localFile", "remoteFile");


rm
void  rm( String, Boolean, Boolean )
Remove a file or directory on the remote computer with options to force deletion of existig files and recursion.
Parameters
String  path  the path
Boolean  force  the force
Boolean  recurse  the recursive

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}


rm
void  rm( String )
Remove a file or directory on the remote computer with options to force deletion of existig files and recursion.
Parameters
String  path  the path

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// set the settings needed to log into the server
// alternative is the use of a keystore instead of a password
var vSettings = plugins.it2be_ftp.createPasswordSettings("host", "user", "password");

// Create a client for the SFTP connection
var vClient = plugins.it2be_ftp.createSFTPclient(vSettings);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (vClient.connect()) {
// Check the status of the connection
application.output(vClient.getStatus());

// Create a list (array) of SFTPFiles
var vList = vClient.list();

// Loop through the SFTPFiles
for (var vIndex = 0 ; vIndex < vList.length ; vIndex++) {
// Retrieve the file at the selected index
var vFile = vList[vIndex];

// Output the name, size and timestamp of the SFTPFile
application.output(vFile.name + " - " + vFile.size + " - " + vFile.timeStamp);

// When the SFTPFile is of file type retrieve the data for it
// Here you could create a method to loop through the folder if
// the file type is a folder
if (vFile.isFile) {
vClient.get(vFile.name, "path/" + vFile.name);
}
}

// Disconnect the client
application.output(vClient.disconnect());
}