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.
Total bytes that have been downloaded on this request so far.
Total number of buffers that have been read so far.
Content of the current download chunk read. File information is incremental so it's possible to capture text and append it to a file incrementally for possibly viewing information while it's downloading.
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.
*** Load libs 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 LPARAMETER lnBytesDownloaded,lnBufferReads,lcCurrentChunk, lnTotalBytes, loFtp DO CASE CASE lnBufferReads > 0 wait window "Downloaded: " + TRANSFORM(lnBytesDownloaded)+ " bytes of " + ; TRANSFORM(lnTotalBytes) + " (Alt-X to cancel)" nowait *** Error CASE lnBufferReader = -1 and loFtp.nError # 0 wait window "An error occurred: " + this.cErrorMsg *** Cancelled CASE lnBufferReads = -1 AND loFtp.lCancelDownload wait window "Download aborted..." timeout 2 *** Completed CASE lnBufferReads = -1 WAIT WINDOW "Download Completed." TIMEOUT 2 ENDCASE RETURN ENDDEFINE
See also:Class wwftp | wwftp::lCancelDownload | wwftp::nFTPWorkBufferSize | Class wwFtp | wwftp::FTPSendFileEx
Comment or report problem with topic