DataFlex
DataFlex
Restart/Resume FTP Upload
See more FTP Examples
Demonstrates how to restart / resume an FTP upload.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sLocalFilename
String sRemoteFilename
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
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 "login"
Set ComPassword Of hoFtp To "password"
// Connect and login to the FTP server.
Get ComConnect Of hoFtp To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Change to the remote directory where the file will be uploaded.
Get ComChangeRemoteDir Of hoFtp "temp" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// In this example, assume that a previous FTP upload failed,
// and the incomplete file (bigFile.zip) exists on the FTP server.
// You only need to set the RestartNext property to resume
// the upload. When RestartNext is set, the next call
// to PutFile (or PutFileFromBinaryData, PutFileFromTextData)
// will automatically resume the upload from the point of failure.
// (The way it works is that the FTP component sends a "SIZE"
// command to the FTP server to find out how many bytes of
// the file already exist on the server. It then begins
// uploading from that point.
// Note: After PutFile is called, the RestartNext property
// is automatically set to false.
Set ComRestartNext Of hoFtp To True
// Upload a file with restart.
Move "bigFile.zip" To sLocalFilename
Move "bigFile.zip" To sRemoteFilename
Get ComPutFile Of hoFtp sLocalFilename sRemoteFilename To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComDisconnect Of hoFtp To iSuccess
Showln "File Uploaded!"
End_Procedure