FTPWI.GetFileSize

number FTPWI.GetFileSize (

string URL,

string Username = "anonymous",

string Password = "guest@",

number Mode = MODE_BINARY,

number Timeout = 20,

number Port = 21,

boolean PassiveMode = true,

function CallbackFunction = nil )

Description

Gets the size of a file (in bytes) located on an FTP site.

Parameters

URL

(string) The full ftp address to the file you want the size of. For example, ftp://ftp.myftpsite.com/updates/myfile.txt.

Username

(string) The name to use to log into the FTP site. The default for anonymous FTP is "anonymous".

Password

(string) The password for the FTP site that goes with the FTP Username. For anonymous FTP, use your email address or the password default "guest@".

Mode

(number) The mode you want to use to access the file. Choose from:

CONSTANT

VALUE

DESCRIPTION

MODE_BINARY

0

Save the file exactly as downloaded. (Default)

MODE_TEXT

1

Convert the file from Unix to Windows text mode, if necessary.

Note: This parameter is mainly present for consistency between FTPWI actions.

Timeout

(number) The maximum time in seconds that the action will wait for a response after attempting to connect. The default value is 20.

Note: Timeout values are interpreted in multiple ways during client server communication. As a result the actual timeout used by the connection may differ from the value specified.

Port

(number) The port to connect to. In most cases the default value of 21 is standard for FTP.

PassiveMode

(boolean) Use passive/firewall mode when accessing the file. Passive mode (also known as "firewall mode") is required whenever you need to transfer files to or from an FTP server from behind a firewall. Passing the default value true enables passive mode and passing false disables it.

Normally, your computer makes a connection to an FTP server, and the FTP server responds by opening a connection back to your computer. This return connection won't work if your computer can't be reached directly from the Internet. In passive mode, both connections are made from your computer, so the FTP server doesn't have to do any connecting-it just waits passively for your computer to make both of the connections to it.

Most servers support passive mode connections, so it's generally best to leave this setting enabled.

CallbackFunction

(function) The name of a function that will be called whenever progress is made in the download operation. (You can use this callback function to display the progress of the download in your own custom way.)

Note: If CallbackFunction is set to nil, then the progress information will be sent to the built-in status dialog, assuming it is currently visible. (You can show or hide the status dialog with a StatusDlg.Show or StatusDlg.Hide action.)

The callback function must be able to receive the following parameter:

Message

(string) Either a blank string ("") or an information message being sent by the server, such as "Resolving host name" or "Connecting to Server."

The callback function should return a boolean value (true or false) indicating whether the file access should continue:

VALUE

DESCRIPTION

true

Continue with the file access.

false

Stop the file access as soon as possible.

Returns

(number) The size of the file on the FTP site (in bytes). If the file's size could not be retrieved, -1 is returned. You can use Application.GetLastError to determine whether this action failed, and why.

See also: Related Actions