wwftp::onftpbufferupdate

Event that fires whenever the buffer is updated by FTPGetFileEx(). This method is passed the current download total and the number of chunks retrieved already. You can set lCancelDownload to .T. to force FTPGetEx to stop the file download.

o.onftpbufferupdate(lnPercent, lnDownloadedBytes, lcRemotePath, lcMode)

Parameters

lnPercentComplete
The percentage complete for the upload in progress. Value is an Integer between 0-100.

lnDownloadedBytes Number of bytes that have been downloaded or uploaded so far.

lcRemotePath
The remote path of the file processing

lcMode
Current process mode:

  • download
  • upload

Remarks

Be careful with what kind of code you put into this 'event' method since it fires on every buffer update. It should be efficient and do little more than check for aborts and provide some visual feedback. Putting code here will slow down downloads.

Example

DO wwFtp

PUBLIC oFTP as wwFTP
oFTP = CREATEOBJECT("wwFtp_Custom")

* ** Abort download with hotkey
ON KEY LABEL ALT-X oFTP.lCancelDownload = .T.

* ** Optional Username and password
* oFTP.cUsername = "rickstrahl"
* oFTP.cPassword = GETSYSTEMPASSWORD()

oFTP.FtpConnect("www.west-wind.com")

* ** Download a file 
IF oFTP.FTPGetFileex("/wwipstuff.zip","d:\temp\wwipstuff.zip") != 0
   ? oFTP.cErrorMsg
ENDIF   

* ** Upload a file
IF oFTP.FTPSendFileEx("d:\sailbig.jpg","/sailbig.jpg") != 0
   ? oFTP.cErrormsg
ENDIF

ON KEY LABEL Alt-X
RETURN


* ** Custom class to override the OnFtpBufferUpdate method
DEFINE CLASS wwFtp_Custom as wwFTP

FUNCTION OnFtpBufferUpdate(lnPercent, lnDownloadedBytes, lcRemotePath, lcMode)
  lcMsg = lcMode + ": " + TRANSFORM(lnPercent) + "% complete. " + lcRemotePath + " - " + TRANSFORM(lnDownloadedBytes) + " bytes"
  ? "* ** " + lcMsg
ENDFUNC

ENDFUNC

See also:

Class wwFtp (deprecated) | wwftp::lCancelDownload | wwftp::nFTPWorkBufferSize | Class wwFtp (deprecated) | wwftp::FTPSendFileEx |

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