Class wwFtpClient

An FTP and FTPS client that allows you to access FTP servers and perform common FTP transfer and management operations.

DO wwFtpClient && Load library and dependencies  
loFtp  = CREATEOBJECT("wwFtpClient")

loFtp.cServer = "someserver.com"
loFtp.nPort = 23        && only needed with custom ports (default is 21)
loFtp.lUseTls = .T.     && Secure Connection
loFtp.cUsername = "crankyFun221"
loFtp.cPassword = "superSeekrit#9"

IF !loFtp.Connect()
	? loFtp.cErrorMsg
	RETURN
ENDIF
? "Connected to " + lcServer	

IF !loFtp.DownloadFile("Tools/jsMinifier.zip", "c:\temp\jsMinifier.zip")
	? loFtp.cErrorMsg
	RETURN
ENDIF	
? "Downloaded " + "Tools/jsMinifier.zip"

lcUploadFile = "Tools/jsMinifier" + SYS(2015) + ".zip"
IF !loFtp.UploadFile("c:\temp\jsMinifier.zip", lcUploadFile)
	? loFtp.cErrorMsg
	RETURN
ENDIF
? "Uploaded " + lcuploadFile

*** provide a folder name (no wildcards)
loCol = loFtp.ListFiles("/Tools")
? TRANSFORM(loCol.Count ) + " matching file(s)"
? loFtp.cErrorMsg
FOR EACH loFile IN loCol FOXOBJECT
   IF ( AT("jsMinifier_",loFile.Name) = 1)
	   ? loFtp.oBridge.ToJson(loFile)  && print out file obj as json
	   IF loFtp.DeleteFile(loFile.FullName)
	      ? "Deleted " + loFile.FullName
	   ENDIF
	   
   ENDIF
ENDFOR

loFtp.Close()

Remarks

Dependencies

This API uses a .NET library to provide FTP functionality.

  • wwIpstuff.dll
  • wwDotnetBridge.dll
  • FluentFtp.dll

Class Members

MemberDescription

OnFtpBufferUpdate

A progress event that is fired as files are downloaded or uploaded providing basic progress information as the upload proceeds.

ChangeDirectory

Changes the active directory on the FTP server. This affects how relative paths are handled.

o.ChangeDirectory(lcFtpPath)

Close

Closes the FTP connections.

o.wwFtpClient.Close

Connect

This establishes the initial connection to the server. The connection needs to stay open for any of the FTP operation commands.

o.Connect(lcServer, lcUsername, lcPassword)

CreateDirectory

Creates a new directory on the server.

o.CreateDirectory(lcPath)

DeleteDirectory

Deletes a directory from the FTP server.

o.wwFtpClient.DeleteDirectory(lcFtpPath)

DeleteFile

Deletes a file from the server.

o.wwFtpClient.DeleteFile(lcFtpPath)

DowloadFile

Downloads a file from the FTP server to a local file.

o.wwFtpClient.DowloadFile(lcFtpPath,lcLocalPath)

ExecuteCommand

FtpCommand

Function: Issue an arbitrary FTP Command Assume: Connection must exist with FtpOpen Pass: Return:

o.ExecuteCommand(lcCommand)

ExecuteDownloadCommand

ExecuteDownloadCommand

Function: Issue an arbitrary FTP Command Assume: Connection must exist with FtpOpen Pass: Return:

o.ExecuteDownloadCommand(lcCommand)

Exists

Checks to see if the remote file exists.

o.Exists(lcRemoteFile)

ListFiles

Retrieves a directory listing from the server with all files returned as a collection.

o.ListFiles(lcFtpPath)

UploadFile

Uploads a file to the server from a local file.

o.wwFtpClient.UploadFile(lcLocalFile, lcFtpPath)

cErrorMsg

Error message set after a method call that fails

cHttpProxyByPass

cHttpProxyName

cHttpProxyPassword

cHttpProxyPort

cHttpProxyUsername

cLogFile

Optional log file that receives ftp log output.

cPassword

Password for authentication with the FTP server.

cServer

Domain name or IP address for the server

cUsername

Username for authentication against the FTP server.

lIgnoreCertificateErrors

Allows you to ignore certificate errors that due to expired, revoked or otherwise invalid certificates on the server.

lpassiveftp

Flag that determines whether to use passive or active FTP

lUseTls

Tsl used for this request (FTPS protocol: FTP over TLS)

nPort

The port to run the FTP connection on

nTimeout

Connection timeout in seconds.

oBridge

wwDotnetBridge Instance that interfaces with the wwFtpClient .NET instance.

oFtpClient

The .NET wwFtpClient instance that interfaces with the Fluent FTP library.

Requirements

Assembly: wwFtpClient.prg wwIpstuff.dll wwDotnetBridge.dll FluentFtp.dll

© West Wind Technologies, 1996-2024 • Updated: 06/25/24
Comment or report problem with topic