|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Ftp
FTP monitoring API
To include in a script add the following to the top of the script file.
var ftp = require('ftp');Example that logs in and verifies that a known file can be downloaded.
var ftp = require('ftp'); test.beginTransaction(); test.beginStep(); ftp.connect("ftp.servername.com"); ftp.login("username", "password"); ftp.setBinary(true); ftp.get("status_check.txt"); ftp.quit(); test.endStep(); test.endTransaction();
Method Summary | |
---|---|
void |
cd(java.lang.String directory)
Change current remote directory |
void |
connect(java.lang.String hostname)
Connect to the given server |
void |
connect(java.lang.String hostname,
int port)
Connect to the given server and port |
void |
connectSSL(java.lang.String hostname,
boolean implicit)
Connect to the given ftps server |
void |
connectSSL(java.lang.String hostname,
int port,
boolean implicit)
Connect to the given ftps server |
void |
enableLogging()
Enable logging of Ftp commands and responses to the |
Bytes |
get(java.lang.String filename)
Download the given filename. |
java.lang.String |
getLastResponse()
Returns the last response from the Ftp server. |
void |
login(java.lang.String username,
java.lang.String password)
Login with the given username and password |
int |
quit()
Quit the session and disconnect from the server |
void |
setActive(boolean active)
Sets active Ftp mode for file transfers. |
void |
setBinary(boolean binary)
Set the Ftp filemode to binary or back to ASCII. |
Method Detail |
---|
void connect(java.lang.String hostname) throws java.lang.Exception
hostname
- the FTP server to connect to
java.lang.Exception
- when unable to connect to the server or when a timeout occurs.void connect(java.lang.String hostname, int port) throws java.lang.Exception
hostname
- the FTP server to connect toport
- the port to connect to
java.lang.Exception
- when unable to connect to the server or when a timeout occurs.void connectSSL(java.lang.String hostname, boolean implicit) throws java.lang.Exception
Both implicit and explicit ftps are supported.
When implicit is specified the default port is 990.
When explicit is specified (implicit set to false) the default port is 21.
hostname
- the ftps server to connect toimplicit
- when set to true ftps implicit mode is used. This means the connection
is made over SSL. When set to false ftps explicit mode is used. This means the
connection starts off as a normal Ftp connection and then is later upgraded to SSL
(before the username and password are sent of course).
java.lang.Exception
- when unable to connect to the server or when a timeout occurs.void connectSSL(java.lang.String hostname, int port, boolean implicit) throws java.lang.Exception
hostname
- the ftps server to connect toport
- the port to connect toimplicit
- when set to true ftps implicit mode is used. This means the connection
is made over SSL. When set to false ftps explicit mode is used. This means the
connection starts off as a normal Ftp connection and then is later upgraded to SSL
(before the username and password are sent of course).
java.lang.Exception
- when unable to connect to the server or when a timeout occurs.void login(java.lang.String username, java.lang.String password) throws java.lang.Exception
username
- the username to login withpassword
- the password to login with
java.lang.Exception
- if unable to login to the server with the given username/password or
if the connection is lost.int quit() throws java.lang.Exception
java.lang.Exception
- when the connection lost or quit command is rejected.void cd(java.lang.String directory) throws java.lang.Exception
directory
- the remote directory to cd into
java.lang.Exception
- when the connection to the server is lost, or the directory
does not exist.Bytes get(java.lang.String filename) throws java.lang.Exception
setBinary(true)to enable binary mode. Files are downloaded in passive mode by default, so passive mode is expected to be supported by the server. Call
setActive(true)to switch to doing file downloads in active mode.
filename
- the filename to download
java.lang.Exception
- when the file exceeds the maximum size, or the file cannot be found.void setBinary(boolean binary) throws java.lang.Exception
binary
- set to true for binary file downloads, false for ASCII.
java.lang.Exception
- when the connection to the server is lost, or won't
accept binary mode.void setActive(boolean active) throws java.lang.Exception
By default passive file transfers are used. Passive transfers require a listening port on the server to be opened by the Ftp server every time a file is downloaded. Active transfers open the listening port on the client. For active transfers to work usually some kind of NAT has to be in place, on our network some locations may not have a NAT in place (Usually Cloud Compute providers don't). For this reason we recommend sticking with the default and only doing passive transfers. Contact support for a list of locations if you must use active mode.
active
- set to true for active file downloading, false for passive file downloading.
java.lang.Exception
- when the connection to the server is lost, or won't
accept the passive/active mode specified.java.lang.String getLastResponse()
void enableLogging()
test.log()output.
|
© 2023 Vercara, LLC. All Rights Reserved. | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |