Constructor
new Ftp(hostNameopt, userNameopt, passwordopt, protocolopt, serverPortopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
hostName |
String |
<optional> |
IP address or host-name of remote server. |
userName |
String |
<optional> |
User-name of account on remote server. |
password |
String |
<optional> |
Password of account on remote server. |
protocol |
String |
<optional> |
Protocol to use. May be FTP, FTPS, FTPSImplicit, SFTP or SCP. |
serverPort |
String |
<optional> |
Port number to connect to on the remote server. |
Members
hostName :String
IP address or host-name of remote server.
Type:
- String
localDirectory :String
- Description:
Current working directory in local virtual file-system. It's used only when uploading or downloading and the local path is not absolute.
- Source:
Current working directory in local virtual file-system. It's used only when uploading or downloading and the local path is not absolute.
Type:
- String
password :String
Password of account on remote server.
Type:
- String
privateKeyFile :String
Virtual file-system path of file containing private key.
Type:
- String
privateKeyPassword :String
Password of file containing private key.
Type:
- String
protocol :String
Protocol to use. May be FTP, FTPS, FTPSImplicit, SFTP or SCP.
Type:
- String
serverDirectory :String
- Description:
Current working directory on remote server. Before connection the value of this field is null unless it's set. If it's set before connection then its value will be the initial working directory. After connection its value will reflect the remote working directory.
- Source:
Current working directory on remote server. Before connection the value of this field is null unless it's set. If it's set before connection then its value will be the initial working directory. After connection its value will reflect the remote working directory.
Type:
- String
serverPort :Number
Port number to connect to on the remote server.
Type:
- Number
userName :String
User-name of account on remote server.
Type:
- String
Methods
close(waitForServerAckopt) → {Ftp}
- Description:
Closes the connection. Note that calling this method is recommended but not essential since all open clients are closed at the end of each request.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
waitForServerAck |
Boolean |
<optional> |
If true then the client will wait for the server to acknowledge that the connection is being close. Default is 'false'. |
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp
connect() → {Ftp}
- Description:
Connect to remote server. Note that calling this method is optional as the client will automatically connect when any other method is called if it hasn't already connected. Calling it explicitly may be useful for error-handling.
- Source:
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp
createFolder(name) → {Ftp}
- Description:
Creates a folder with the given name under the current working directory
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of directory to create. |
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp
download(remotePath, localPathopt) → {Ftp}
- Description:
Downloads a file from the remote server to the local virtual file-system.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
remotePath |
String | Path or name of the file to be downloaded from the remote file-system. |
|
localPath |
String |
<optional> |
Path of the file being downloaded to the local virtual file-system. |
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp
exists(remotePath) → {String}
- Description:
Tests whether or not a file or directory exists on the remote server. Note that this method doesn't strictly return a boolean. It will return false if the file/directory doesn't exist, but if the it does exist then the type ("file" or "directory") is returned. These are truthy values so the return values may be used in boolean expressions.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
remotePath |
String | Path or name of the file or directory in the remote file-system. |
Returns:
Returns "file" or "directory" if either of these exists and false otherwise.
- Type
- String
getAdvancedProperty(propertyName)
- Description:
Get the value of a SecureFTPConnection property. The JSS Ftp class is implemented by EnterpriseDT's secure FTP .NET component, SecureFTPConnection. This class is very mature and has many properties that are not exposed in the JSS Ftp class. Use this method to get the value of these properties.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
String | Name of property to get. |
list(remotePathopt) → {Array.<FileInfo>}
- Description:
Returns a listing of the remote directory in the form of an array of FileInfo objects.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
remotePath |
String |
<optional> |
Path or name of the directory to be listed in the remote file-system. |
Returns:
Array of FileInfo objects each representing a file or a folder.
- Type
- Array.<FileInfo>
listNames(remotePathopt) → {Array.<String>}
- Description:
Returns a listing of the remote directory in the form of an array of strings being the names of the files and directories (without paths).
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
remotePath |
String |
<optional> |
Path or name of the directory to be listed in the remote file-system. |
Returns:
Array of strings being the names of the files and directories (without paths).
- Type
- Array.<String>
move(fromRemotePath, toRemotePath) → {Ftp}
- Description:
Moves or renames the given file or directory from one path or name to another. Some servers support renaming but not moving.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fromRemotePath |
String | Path or name of the existing file or directory to moved in the remote file-system. |
toRemotePath |
String | Path or name of the file or directory to move it to in the remote file-system. |
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp
remove(remotePath, recursiveopt) → {Ftp}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
remotePath |
String | Path or name of the file or directory to be deleted from the remote file-system. |
||
recursive |
String |
<optional> |
false
|
Remove all files and subdirectories of the directory as well. |
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp
setAdvancedProperty(propertyName, propertyValue)
- Description:
Set a SecureFTPConnection property. The JSS Ftp class is implemented by EnterpriseDT's secure FTP .NET component, SecureFTPConnection. This class is very mature and has many properties that are not exposed in the JSS Ftp class. Use this method to set these properties. Properties that have non-primitive types must be initialized using .NET objects, which can be instantiated in JSS by specifying their full name, e.g. new System.Text.StringBuilder().
- Source:
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
String | Name of property to set. |
propertyValue |
Object | Value to set property to. |
upload(localPath, remotePathopt) → {Ftp}
- Description:
Uploads a file from the local virtual file-system to the remote server.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
localPath |
String | Path of the file to be uploaded from the local virtual file-system. |
|
remotePath |
String |
<optional> |
Path or name of the file being uploaded to the remote file-system. |
Returns:
A reference to 'this' object is returned so that methods may be chained together (see class description).
- Type
- Ftp