IP*Works!

ipworks
Class Ftp

java.lang.Object
  |
  +--ipworks.Ftp

public class Ftp
extends java.lang.Object

The FTP control can be used to transfer files to and from FTP servers using the FTP Protocol.

The FTP control implements a standard FTP client as specified in RFC 959 and RFC 1579.

The first step in using the control is specifying the RemoteHost , User and Password . The file to upload to or download from is given by the RemoteFile property. The file to download to or upload from is specified by LocalFile . The current path in the server is specified by the RemotePath property. The Passive property is especially useful if the client is behind a firewall which inhibits incoming connections to higher ports.

The control operates by calling methods or setting appropriate values to the Action property. If LocalFile is set to something other than an empty string, then files are received in LocalFile , otherwise the data is received through the Transfer event . StartTransfer and EndTransfer are fired at the beginning and end of transmission.

The PITrail event traces the interaction between the client and the server (the FTP Protocol Interface connection).

Directory listings are received through the DirList event.


Field Summary
static int ftpAbort
           
static int ftpAppend
           
static int ftpDeleteFile
           
static int ftpDownload
           
static int ftpIdle
           
static int ftpListDirectory
           
static int ftpListDirectoryLong
           
static int ftpLogoff
           
static int ftpLogon
           
static int ftpMakeDirectory
           
static int ftpRemoveDirectory
           
static int ftpRenameFile
           
static int ftpStoreUnique
           
static int ftpUpload
           
static int fwNone
           
static int fwSOCKS4
           
static int fwSOCKS5
           
static int fwTunnel
           
static int tmASCII
           
static int tmBinary
           
static int tmDefault
           
 
Constructor Summary
Ftp()
           
 
Method Summary
 void abort()
          Abort Current Upload/Download.
 void addFtpEventListener(FtpEventListener l)
           
 void append()
          Append data from LocalFile to a remote file RemoteFile on an FTP server.
 void deleteFile()
          Delete RemoteFile from an FTP server.
 void download()
          Download a RemoteFile from an FTP server.
 void fireDirList(java.lang.String dirEntry, java.lang.String fileName, boolean isDir, int fileSize, java.lang.String fileTime)
          Fired when a directory entry is received.
 void fireEndTransfer()
          Fired when a file completes downloading/uploading.
 void fireError(int errorCode, java.lang.String description)
          Information about errors during data delivery.
 void firePITrail(int direction, java.lang.String message)
          Traces the commands sent to the server, and the respective replies.
 void fireStartTransfer()
          Fired when a file starts downloading/uploading.
 void fireTransfer(int bytesTransferred, byte[] text)
          Fired during file download/upload.
 int getAction()
          An action code for the component.
 java.lang.String getAltFile()
          The new name for RemoteFile when Action is set to Rename .
 byte[] getFirewallData()
          Used to send other data to firewall.
 java.lang.String getFirewallHost()
          Name or IP address of firewall (optional).
 java.lang.String getFirewallPassword()
          A password if authentication is to be used connecting through the firewall.
 int getFirewallPort()
          Port of the firewall to connect to.
 int getFirewallType()
          Determines the type of firewall to connect through.
 java.lang.String getFirewallUser()
          A user name if authentication is to be used connecting through a firewall.
 java.lang.String getLastReply()
          The last reply from the server.
 java.lang.String getLocalFile()
          The path to a local file for download/upload.
 java.lang.String getLocalHost()
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 java.lang.String getPassword()
          The password to login with.
 java.lang.String getRemoteFile()
          The name of the remote file for uploading/downloading.
 java.lang.String getRemoteHost()
          The domain name or IP address of the FTP server.
 java.lang.String getRemotePath()
          The current path in the FTP server.
 int getRemotePort()
          The port for the FTP service (default is 21).
 java.lang.String getStartByte()
          The byte index in RemoteFile and LocalFile where to start the transmission.
 int getTimeout()
          A timeout for the component.
 int getTransferMode()
          The transfer mode (ASCII or Binary).
 java.lang.String getUser()
          The user id to login as.
 void interrupt()
          Interrupt the Action in progress (if any).
 boolean isConnected()
          Shows whether the component is connected.
 boolean isPassive()
          Controls whether to direct the server into passive mode especially if behind a firewall.
 void listDirectory()
          List the current directory specified by RemotePath on an FTP server.
 void listDirectoryLong()
          List extended directory information for RemotePath .
 void logoff()
          Logoff from the FTP server by posting a QUIT command.
 void logon()
          Logon to the FTP server using the current User and Password .
 void makeDirectory()
          Create a directory on an FTP server.
 void removeDirectory()
          Remove a directory specified by RemoteFile from an FTP server.
 void removeFtpEventListener(FtpEventListener l)
           
 void renameFile()
          Change the name of RemoteFile to AltFile on an FTP server.
 void setAction(int action)
          An action code for the component.
 void setAltFile(java.lang.String altFile)
          The new name for RemoteFile when Action is set to Rename .
 void setCommand(java.lang.String command)
          Can be used to send additional commands directly to the FTP server.
 void setFirewallData(byte[] firewallData)
          Used to send other data to firewall.
 void setFirewallHost(java.lang.String firewallHost)
          Name or IP address of firewall (optional).
 void setFirewallPassword(java.lang.String firewallPassword)
          A password if authentication is to be used connecting through the firewall.
 void setFirewallPort(int firewallPort)
          Port of the firewall to connect to.
 void setFirewallType(int firewallType)
          Determines the type of firewall to connect through.
 void setFirewallUser(java.lang.String firewallUser)
          A user name if authentication is to be used connecting through a firewall.
 void setLocalFile(java.lang.String localFile)
          The path to a local file for download/upload.
 void setLocalHost(java.lang.String localHost)
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 void setPassive(boolean passive)
          Controls whether to direct the server into passive mode especially if behind a firewall.
 void setPassword(java.lang.String password)
          The password to login with.
 void setRemoteFile(java.lang.String remoteFile)
          The name of the remote file for uploading/downloading.
 void setRemoteHost(java.lang.String remoteHost)
          The domain name or IP address of the FTP server.
 void setRemotePath(java.lang.String remotePath)
          The current path in the FTP server.
 void setRemotePort(int remotePort)
          The port for the FTP service (default is 21).
 void setStartByte(java.lang.String startByte)
          The byte index in RemoteFile and LocalFile where to start the transmission.
 void setTimeout(int timeout)
          A timeout for the component.
 void setTransferMode(int transferMode)
          The transfer mode (ASCII or Binary).
 void setUser(java.lang.String user)
          The user id to login as.
 void storeUnique()
          Upload a file with a Unique Name to an FTP server.
 void upload()
          Upload a file specified by LocalFile to an FTP server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ftpIdle

public static final int ftpIdle

ftpAbort

public static final int ftpAbort

ftpLogon

public static final int ftpLogon

ftpLogoff

public static final int ftpLogoff

ftpDownload

public static final int ftpDownload

ftpUpload

public static final int ftpUpload

ftpDeleteFile

public static final int ftpDeleteFile

ftpRenameFile

public static final int ftpRenameFile

ftpListDirectory

public static final int ftpListDirectory

ftpListDirectoryLong

public static final int ftpListDirectoryLong

ftpMakeDirectory

public static final int ftpMakeDirectory

ftpRemoveDirectory

public static final int ftpRemoveDirectory

ftpAppend

public static final int ftpAppend

ftpStoreUnique

public static final int ftpStoreUnique

fwNone

public static final int fwNone

fwTunnel

public static final int fwTunnel

fwSOCKS4

public static final int fwSOCKS4

fwSOCKS5

public static final int fwSOCKS5

tmDefault

public static final int tmDefault

tmASCII

public static final int tmASCII

tmBinary

public static final int tmBinary
Constructor Detail

Ftp

public Ftp()
Method Detail

getAction

public int getAction()
An action code for the component. Setting the Action property to a valid action code makes the control perform the associated action. If the action completes successfully, execution continues normally, and Action is reset to 0 (Idle). If an error happens, then an IPWorksException exception is raised.

The following are the possible values for the Action property and the corresponding descriptions:

ftpIdle (0)
Default action. It can also be used to interrupt the current operation.
ftpAbort (1)
Sends an ABOR command to the FTP server. It is used to interrupt file uploads/downloads.
ftpLogon (2)
Logon to the FTP server using the current User and Password . If TransferMode is not 0 (Default), then the FTP transfer mode is set to the appropriate value.
ftpLogoff (3)
Logoff from the FTP server by posting a QUIT command. If that fails, the connection is terminated by the local host.
ftpDownload (4)
The remote file specified by RemoteFile is downloaded to the local file specified by LocalFile , or it is retrieved through the Transfer event, if the LocalFile property is "" (empty string). RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpUpload (5)
The local file specified by LocalFile is uploaded to the remote file specified by RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon . Check also the ftpAppend action for appending a file to the server.
ftpDeleteFile (6)
The remote file(s) specified by RemoteFile are deleted. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpRenameFile (7)
The name of remote file specified by RemoteFile is changed to the value of AltFile . RemoteFile and AltFile are either absolute paths on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpListDirectory (8)
A listing is requested for the directory (or file mask) specified in RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The file listing is received through the DirList event. Only file names are returned. If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpListDirectoryLong (9)
A listing is requested for the directory (or file mask) specified in RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The file listing is received through the DirList event. Extended file information is returned. If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpMakeDirectory (10)
A directory with path specified by RemoteFile is created on the FTP server. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpRemoveDirectory (11)
A directory with path specified by RemoteFile is deleted on the FTP server. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpAppend (12)
This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site. Similar to the ftpUpload action but the local file specified by LocalFile is appended to RemoteFile on the server as opposed to replacing it as done by the ftpUpload action. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The server will create a file with that name if it doesn't already exist (similar to Upload). If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpStoreUnique (13)
Similar to the ftpUpload action but the server determines a unique name for the LocalFile to be saved on the current directory given by RemotePath . The server includes the new name of the file in its response. The user should check the PITrail event, or LastReply property to retrieve this generated filename.


setAction

public void setAction(int action)
               throws IPWorksException
An action code for the component. Setting the Action property to a valid action code makes the control perform the associated action. If the action completes successfully, execution continues normally, and Action is reset to 0 (Idle). If an error happens, then an IPWorksException exception is raised.

The following are the possible values for the Action property and the corresponding descriptions:

ftpIdle (0)
Default action. It can also be used to interrupt the current operation.
ftpAbort (1)
Sends an ABOR command to the FTP server. It is used to interrupt file uploads/downloads.
ftpLogon (2)
Logon to the FTP server using the current User and Password . If TransferMode is not 0 (Default), then the FTP transfer mode is set to the appropriate value.
ftpLogoff (3)
Logoff from the FTP server by posting a QUIT command. If that fails, the connection is terminated by the local host.
ftpDownload (4)
The remote file specified by RemoteFile is downloaded to the local file specified by LocalFile , or it is retrieved through the Transfer event, if the LocalFile property is "" (empty string). RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpUpload (5)
The local file specified by LocalFile is uploaded to the remote file specified by RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon . Check also the ftpAppend action for appending a file to the server.
ftpDeleteFile (6)
The remote file(s) specified by RemoteFile are deleted. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpRenameFile (7)
The name of remote file specified by RemoteFile is changed to the value of AltFile . RemoteFile and AltFile are either absolute paths on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpListDirectory (8)
A listing is requested for the directory (or file mask) specified in RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The file listing is received through the DirList event. Only file names are returned. If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpListDirectoryLong (9)
A listing is requested for the directory (or file mask) specified in RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The file listing is received through the DirList event. Extended file information is returned. If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpMakeDirectory (10)
A directory with path specified by RemoteFile is created on the FTP server. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpRemoveDirectory (11)
A directory with path specified by RemoteFile is deleted on the FTP server. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpAppend (12)
This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site. Similar to the ftpUpload action but the local file specified by LocalFile is appended to RemoteFile on the server as opposed to replacing it as done by the ftpUpload action. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The server will create a file with that name if it doesn't already exist (similar to Upload). If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .
ftpStoreUnique (13)
Similar to the ftpUpload action but the server determines a unique name for the LocalFile to be saved on the current directory given by RemotePath . The server includes the new name of the file in its response. The user should check the PITrail event, or LastReply property to retrieve this generated filename.


getAltFile

public java.lang.String getAltFile()
The new name for RemoteFile when Action is set to Rename . See the description of the Action property for more information.


setAltFile

public void setAltFile(java.lang.String altFile)
                throws IPWorksException
The new name for RemoteFile when Action is set to Rename . See the description of the Action property for more information.


setCommand

public void setCommand(java.lang.String command)
                throws IPWorksException
Can be used to send additional commands directly to the FTP server. Check the LastReply property and/or trap the PITrail events comming from the server to get the response.


isConnected

public boolean isConnected()
Shows whether the component is connected. Use this property to determine whether the control is connected to the remote host or not.


getFirewallData

public byte[] getFirewallData()
Used to send other data to firewall. When the firewall is a tunneling proxy, use this property to to send custom (additional) headers to the firewall (e.g. headers for custom authentication schemes).


setFirewallData

public void setFirewallData(byte[] firewallData)
                     throws IPWorksException
Used to send other data to firewall. When the firewall is a tunneling proxy, use this property to to send custom (additional) headers to the firewall (e.g. headers for custom authentication schemes).


getFirewallHost

public java.lang.String getFirewallHost()
Name or IP address of firewall (optional). If a FirewallHost is given, requested connections will be authenticated through the specified firewall when connecting.

If the FirewallHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the search is not successful, an error is returned.


setFirewallHost

public void setFirewallHost(java.lang.String firewallHost)
                     throws IPWorksException
Name or IP address of firewall (optional). If a FirewallHost is given, requested connections will be authenticated through the specified firewall when connecting.

If the FirewallHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the FirewallHost property is set to the corresponding address. If the search is not successful, an error is returned.


getFirewallPassword

public java.lang.String getFirewallPassword()
A password if authentication is to be used connecting through the firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


setFirewallPassword

public void setFirewallPassword(java.lang.String firewallPassword)
                         throws IPWorksException
A password if authentication is to be used connecting through the firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


getFirewallPort

public int getFirewallPort()
Port of the firewall to connect to. The TCP port for the FirewallHost . See the description of the FirewallHost property for details.

Note that the FirewallPort is set automatically when FirewallType is set to a valid value. See the description of the FirewallType property for details.


setFirewallPort

public void setFirewallPort(int firewallPort)
                     throws IPWorksException
Port of the firewall to connect to. The TCP port for the FirewallHost . See the description of the FirewallHost property for details.

Note that the FirewallPort is set automatically when FirewallType is set to a valid value. See the description of the FirewallType property for details.


getFirewallType

public int getFirewallType()
Determines the type of firewall to connect through. The applicable values are the following:
fwNone (0)
No firewall (default setting).
fwTunnel (1)
Connect through a tunneling proxy. FirewallPort is set to 80.
fwSOCKS4 (2)
Connect through a SOCKS4 Proxy. FirewallPort is set to 1080.
fwSOCKS5 (3)
Connect through a SOCKS5 Proxy. FirewallPort is set to 1080.


setFirewallType

public void setFirewallType(int firewallType)
                     throws IPWorksException
Determines the type of firewall to connect through. The applicable values are the following:
fwNone (0)
No firewall (default setting).
fwTunnel (1)
Connect through a tunneling proxy. FirewallPort is set to 80.
fwSOCKS4 (2)
Connect through a SOCKS4 Proxy. FirewallPort is set to 1080.
fwSOCKS5 (3)
Connect through a SOCKS5 Proxy. FirewallPort is set to 1080.


getFirewallUser

public java.lang.String getFirewallUser()
A user name if authentication is to be used connecting through a firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


setFirewallUser

public void setFirewallUser(java.lang.String firewallUser)
                     throws IPWorksException
A user name if authentication is to be used connecting through a firewall. if FirewallHost is specified, the FirewallUser and FirewallPassword properties are used to connect and authenticate to the given firewall. If the authentication fails, a trappable error is fired.


getLastReply

public java.lang.String getLastReply()
The last reply from the server. This is the last reply received from the server. It can be used for information purposes. The same information and more can also be retrieved through the PITrail event.


getLocalFile

public java.lang.String getLocalFile()
The path to a local file for download/upload. If the file exists, it is overwritten. The LocalFile property is used by the Upload and ftpDownload actions. See the description of the Action property for more information.


setLocalFile

public void setLocalFile(java.lang.String localFile)
                  throws IPWorksException
The path to a local file for download/upload. If the file exists, it is overwritten. The LocalFile property is used by the Upload and ftpDownload actions. See the description of the Action property for more information.


getLocalHost

public java.lang.String getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


setLocalHost

public void setLocalHost(java.lang.String localHost)
                  throws IPWorksException
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


isPassive

public boolean isPassive()
Controls whether to direct the server into passive mode especially if behind a firewall. Many firewalls will not allow the FTP server to open a connection from outside to the higher ports where the FTP client control expects them. If Passive is set to TRUE , the control will use the PASV instead of the PORT command and will thus direct the server into passive mode: connections are initiated only by the client.


setPassive

public void setPassive(boolean passive)
                throws IPWorksException
Controls whether to direct the server into passive mode especially if behind a firewall. Many firewalls will not allow the FTP server to open a connection from outside to the higher ports where the FTP client control expects them. If Passive is set to TRUE , the control will use the PASV instead of the PORT command and will thus direct the server into passive mode: connections are initiated only by the client.


getPassword

public java.lang.String getPassword()
The password to login with. This property must be set before the control connects to the FTP server.


setPassword

public void setPassword(java.lang.String password)
                 throws IPWorksException
The password to login with. This property must be set before the control connects to the FTP server.


getRemoteFile

public java.lang.String getRemoteFile()
The name of the remote file for uploading/downloading. The RemoteFile is either an absolute file path, or a relative path based on RemotePath .

A number of actions use RemoteFile as an argument. See the description of the Action property for more information.


setRemoteFile

public void setRemoteFile(java.lang.String remoteFile)
                   throws IPWorksException
The name of the remote file for uploading/downloading. The RemoteFile is either an absolute file path, or a relative path based on RemotePath .

A number of actions use RemoteFile as an argument. See the description of the Action property for more information.


getRemoteHost

public java.lang.String getRemoteHost()
The domain name or IP address of the FTP server. The RemoteHost property specifies the IP address (IP number in dotted internet format) or Domain Name of the FTP server. It is set before a connection is attempted and cannot be changed once a connection is in progress.

If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.


setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
                   throws IPWorksException
The domain name or IP address of the FTP server. The RemoteHost property specifies the IP address (IP number in dotted internet format) or Domain Name of the FTP server. It is set before a connection is attempted and cannot be changed once a connection is in progress.

If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.


getRemotePath

public java.lang.String getRemotePath()
The current path in the FTP server. The RemotePath shows the current working directory on the FTP server. It can also be used to change the working directory by setting it to an absolute directory path, or a relative path with respect to the existing value of RemotePath .

If the first two characters of the new path are "..", then a change to one level above in the directory tree is performed.

Setting RemotePath causes the control to sent the appropriate command to the remote server only if connected.


setRemotePath

public void setRemotePath(java.lang.String remotePath)
                   throws IPWorksException
The current path in the FTP server. The RemotePath shows the current working directory on the FTP server. It can also be used to change the working directory by setting it to an absolute directory path, or a relative path with respect to the existing value of RemotePath .

If the first two characters of the new path are "..", then a change to one level above in the directory tree is performed.

Setting RemotePath causes the control to sent the appropriate command to the remote server only if connected.


getRemotePort

public int getRemotePort()
The port for the FTP service (default is 21). A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed while a connection is in progress. Any attempt to change the RemotePort while connected will fail with an error.


setRemotePort

public void setRemotePort(int remotePort)
                   throws IPWorksException
The port for the FTP service (default is 21). A valid port number (a value between 1 and 65535) is required for the connection to take place. The property must be set before a connection is attempted and cannot be changed while a connection is in progress. Any attempt to change the RemotePort while connected will fail with an error.


getStartByte

public java.lang.String getStartByte()
The byte index in RemoteFile and LocalFile where to start the transmission. The StartByte contains a zero-based index in both RemoteFile and LocalFile that determines the point where the transmission of data starts from. This is useful for resuming interrupted downloads and uploads of files from FTP servers.

Once set, the StartByte index is used for all future downloads/uploads. The property must be reset to "0" for normal downloads/uploads.

The type of the property is a string instead of numeric to allow for certain implementations that expect an alphanumeric marker of the start index.

In the Transfer event, the TransferredBytes parameter will include the bytes skipped (i.e. it will show StartByte more bytes than actually transferred).

NOTE: some FTP servers may not support the FTP 'REST' command. If that is the case with the server you are accessing, you will not be able to use the StartByte property.


setStartByte

public void setStartByte(java.lang.String startByte)
                  throws IPWorksException
The byte index in RemoteFile and LocalFile where to start the transmission. The StartByte contains a zero-based index in both RemoteFile and LocalFile that determines the point where the transmission of data starts from. This is useful for resuming interrupted downloads and uploads of files from FTP servers.

Once set, the StartByte index is used for all future downloads/uploads. The property must be reset to "0" for normal downloads/uploads.

The type of the property is a string instead of numeric to allow for certain implementations that expect an alphanumeric marker of the start index.

In the Transfer event, the TransferredBytes parameter will include the bytes skipped (i.e. it will show StartByte more bytes than actually transferred).

NOTE: some FTP servers may not support the FTP 'REST' command. If that is the case with the server you are accessing, you will not be able to use the StartByte property.


getTimeout

public int getTimeout()
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not "freeze" and always remains responsive.


setTimeout

public void setTimeout(int timeout)
                throws IPWorksException
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control will use DoEvents to enter an efficient wait loop during any potential waiting period, making sure that all system events are processed immediately as they arrive. This ensures that the host application does not "freeze" and always remains responsive.


getTransferMode

public int getTransferMode()
The transfer mode (ASCII or Binary). If the value is 0 (default), the initial server mode will be used. The valid options for the TransferMode property are as follows:
tmDefault (0)
The initial mode of the FTP server is taken. No change.
tmASCII (1)
Files are transferred in ASCII mode (TYPE A).
tmBinary (2)
Files are transferred in Binary mode (TYPE I).


setTransferMode

public void setTransferMode(int transferMode)
                     throws IPWorksException
The transfer mode (ASCII or Binary). If the value is 0 (default), the initial server mode will be used. The valid options for the TransferMode property are as follows:
tmDefault (0)
The initial mode of the FTP server is taken. No change.
tmASCII (1)
Files are transferred in ASCII mode (TYPE A).
tmBinary (2)
Files are transferred in Binary mode (TYPE I).


getUser

public java.lang.String getUser()
The user id to login as. This property must be set before the control connects to the FTP server.


setUser

public void setUser(java.lang.String user)
             throws IPWorksException
The user id to login as. This property must be set before the control connects to the FTP server.


fireDirList

public void fireDirList(java.lang.String dirEntry,
                        java.lang.String fileName,
                        boolean isDir,
                        int fileSize,
                        java.lang.String fileTime)
Fired when a directory entry is received. (Called internally to dispatch the event.)
See Also:
FtpDirListEvent

fireEndTransfer

public void fireEndTransfer()
Fired when a file completes downloading/uploading. (Called internally to dispatch the event.)
See Also:
FtpEndTransferEvent

fireError

public void fireError(int errorCode,
                      java.lang.String description)
Information about errors during data delivery. (Called internally to dispatch the event.)
See Also:
FtpErrorEvent

firePITrail

public void firePITrail(int direction,
                        java.lang.String message)
Traces the commands sent to the server, and the respective replies. (Called internally to dispatch the event.)
See Also:
FtpPITrailEvent

fireStartTransfer

public void fireStartTransfer()
Fired when a file starts downloading/uploading. (Called internally to dispatch the event.)
See Also:
FtpStartTransferEvent

fireTransfer

public void fireTransfer(int bytesTransferred,
                         byte[] text)
Fired during file download/upload. (Called internally to dispatch the event.)
See Also:
FtpTransferEvent

abort

public void abort()
           throws IPWorksException
Abort Current Upload/Download. Sends an ABOR command to the FTP server. It is used to interrupt file uploads/downloads.

Calling this method is equivalent to setting the Action property to ftpAbort .


append

public void append()
            throws IPWorksException
Append data from LocalFile to a remote file RemoteFile on an FTP server. This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site. Similar to the ftpUpload action but the local file specified by LocalFile is appended to RemoteFile on the server as opposed to replacing it as done by the ftpUpload action. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The server will create a file with that name if it doesn't already exist (similar to Upload). If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpAppend .


deleteFile

public void deleteFile()
                throws IPWorksException
Delete RemoteFile from an FTP server. The remote file(s) specified by RemoteFile are deleted. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpDeleteFile .


download

public void download()
              throws IPWorksException
Download a RemoteFile from an FTP server. The remote file specified by RemoteFile is downloaded to the local file specified by LocalFile , or it is retrieved through the Transfer event, if the LocalFile property is "" (empty string). RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpDownload .


interrupt

public void interrupt()
               throws IPWorksException
Interrupt the Action in progress (if any). Calling this method is equivalent to setting the Action property to Idle (0) .


listDirectory

public void listDirectory()
                   throws IPWorksException
List the current directory specified by RemotePath on an FTP server. A listing is requested for the directory (or file mask) specified in RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The file listing is received through the DirList event. Only file names are returned. If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpListDirectory .


listDirectoryLong

public void listDirectoryLong()
                       throws IPWorksException
List extended directory information for RemotePath . A listing is requested for the directory (or file mask) specified in RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . The file listing is received through the DirList event. Extended file information is returned. If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpListDirectoryLong .


logoff

public void logoff()
            throws IPWorksException
Logoff from the FTP server by posting a QUIT command. Logoff from the FTP server by posting a QUIT command. If that fails, the connection is terminated by the local host.

Calling this method is equivalent to setting the Action property to ftpLogoff .


logon

public void logon()
           throws IPWorksException
Logon to the FTP server using the current User and Password . Logon to the FTP server using the current User and Password . If TransferMode is not 0 (Default), then the FTP transfer mode is set to the appropriate value.

Calling this method is equivalent to setting the Action property to ftpLogon .


makeDirectory

public void makeDirectory()
                   throws IPWorksException
Create a directory on an FTP server. A directory with path specified by RemoteFile is created on the FTP server. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpMakeDirectory .


removeDirectory

public void removeDirectory()
                     throws IPWorksException
Remove a directory specified by RemoteFile from an FTP server. A directory with path specified by RemoteFile is deleted on the FTP server. RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpRemoveDirectory .


renameFile

public void renameFile()
                throws IPWorksException
Change the name of RemoteFile to AltFile on an FTP server. The name of remote file specified by RemoteFile is changed to the value of AltFile . RemoteFile and AltFile are either absolute paths on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon .

Calling this method is equivalent to setting the Action property to ftpRenameFile .


storeUnique

public void storeUnique()
                 throws IPWorksException
Upload a file with a Unique Name to an FTP server. Similar to the ftpUpload action but the server determines a unique name for the LocalFile to be saved on the current directory given by RemotePath . The server includes the new name of the file in its response. The user should check the PITrail event, or LastReply property to retrieve this generated filename.

Calling this method is equivalent to setting the Action property to ftpStoreUnique .


upload

public void upload()
            throws IPWorksException
Upload a file specified by LocalFile to an FTP server. The local file specified by LocalFile is uploaded to the remote file specified by RemoteFile . RemoteFile is either an absolute path on the server, or a path relative to RemotePath . If there is no FTP session in place, one is automatically created by first setting Action to ftpLogon . Check also the ftpAppend action for appending a file to the server.

Calling this method is equivalent to setting the Action property to ftpUpload .


addFtpEventListener

public void addFtpEventListener(FtpEventListener l)
                         throws java.util.TooManyListenersException

removeFtpEventListener

public void removeFtpEventListener(FtpEventListener l)

IP*Works!

Copyright (c) 2001 /n software inc. - All rights reserved.