Overview
TheConnectionOptions interface defines optional configuration parameters for FTP client connections. All fields are optional and have sensible defaults.
Type Definition
Fields
The username for FTP authentication.When not specified, the client uses “anonymous” as the default username, which is standard for public FTP servers.Example:
The password for FTP authentication.When not specified, the client uses “anonymous” as the default password. For anonymous FTP access, this is typically an email address or simply “anonymous”.Example:
The port number to connect to on the FTP server.The standard FTP control connection port is 21. You may need to specify a different port if your FTP server uses a non-standard configuration.Example:
The port number to use for active mode data connections.In active FTP mode, the server initiates data connections back to the client. The standard port for this is 20. Most modern FTP clients use passive mode instead, where the client initiates all connections.Example:
The IP address to use for active mode data connections.This specifies the IP address where the server should connect back to for active mode transfers. In most Cloudflare Workers scenarios, passive mode is preferred.Example:
Whether to use IPv6 for active mode data connections.When set to
true, the client will use IPv6 addressing for active mode connections. This requires both the client and server to support IPv6.Example:Whether to use secure FTP connections via STARTTLS.When set to
true, the client will:- Check if the server advertises AUTH TLS support via the FEAT command
- Initiate a STARTTLS handshake to encrypt the control connection
- Enable TLS for data channel transfers using PROT P
Usage Examples
Anonymous Connection
Authenticated Connection
Secure Connection with TLS
Custom Port Configuration
Default Configuration
When you create an FTPClient without providing options, or when you omit specific fields, the following defaults are used:See Also
- FTPClient - Main FTP client class
- FTPFileInfo - File information type returned by stat operations