DataFlex
DataFlex
Connect Through a Traditional FTP Proxy
See more FTP Examples
Demonstrates connecting through a traditional FTP application proxy or firewall using ProxyHostname, ProxyPort, ProxyUsername, ProxyPassword, and ProxyMethod.
Background: A traditional FTP proxy speaks FTP and relays your login to the real server using one of several site-specific handshake sequences — which is why
ProxyMethod exists: it selects the exact USER/PASS/SITE order the proxy expects (0 means no FTP proxy). The proxy's own credentials are separate from the FTP server login. Choose the ProxyMethod value that matches your firewall's documented behavior.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myFtpLogin"
// The FTP proxy/firewall to connect through.
Set ComProxyHostname Of hoFtp To "ftp-proxy.example.com"
Set ComProxyPort Of hoFtp To 21
// The proxy's own credentials (distinct from the FTP server login).
Set ComProxyUsername Of hoFtp To "myProxyLogin"
Set ComProxyPassword Of hoFtp To "myProxyPassword"
// ProxyMethod selects the login sequence the proxy expects. 0 (default) means no FTP proxy;
// values 1 and up select specific USER/PASS/SITE sequences documented for the property.
Set ComProxyMethod Of hoFtp To 1
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
Set ComPassword Of hoFtp To "myPassword"
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Connected through the FTP proxy."
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure