MBS CURL FTP Upload fails for last file

All,

I ran into a strange problem. I’m iterating through all files in a folder and for every file I bump into, I upload it to FTP.
Works fine for all files, but the last one is always 0 bytes on the server. I spent all morning trying to understand why this happens on the last file…

Could someone help me understand this?

thanks

gert


Dim JobFolder As FolderItem
JobFolder = New FolderItem(XojoIOjobFolder.Path, FolderItem.PathTypeNative)

dim d2 as new UploadCURL
d2.OptionUsername = "123"
d2.OptionPassword = "xyz"
d2.CollectDebugData = true
d2.OptionVerbose = true
d2.OptionFTPPort="21"
d2.OptionUpload=true
dim e as integer

For i As Integer = 1 To JobFolder.Count
  d2.OptionURL="sftp://servername.here/dir/"+JobFolder.Item(i).Name
  if not d2.OpenMTInputFile(JobFolder.Item(i)) then
    MsgBox "Error: " + d2.OptionURL
  end if
  e=d2.Perform
  
  Select case e
  case d2.kError_LOGIN_DENIED
    MsgBox "Wrong password."
  case d2.kError_UNSUPPORTED_PROTOCOL 
    MsgBox "Protocol not implemented."
  case d2.kError_OK
    MsgBox "Upload done: " + JobFolder.Item(i).Name
  else
    MsgBox "Result: "+str(e)
  end select
  
  d2.CloseMTInputFile

Next

Exception oobe As OutOfBoundsException
  MsgBox "Error: "+ oobe.Message

Well, I think you should put item(i) in local variable instead of calling it three times.
Than you may want to check if it’s a directory or invisible and skip those.

And for the last transfer, get the d2.DebugData in a property to read.

Thanks Christian – with the debugdata I could find that one of the files wasn’t properly closed and therefor could not be uploaded. Fixed it.