upload file to FTP

Primary tabs



I am trying to upload a file to a ftp site using following code.
Problem is file is getting upload but there is no data. Can you plz advise where I am getting lost.
Also my files are with big data, 2+ GB, as far as know this ftp upload will not effect on my cache.dat size. Plz correct if my understanding is not correct.

Set ftp = ##class(%Net.FtpSession).%New()
set sc = ftp.Connect("myFtpServer","myUserID","myPswd")
Set filestream = ##class(%Library.FileCharacterStream).%New()
Set sc = filestream.LinkToFile("\Temp\GaganTest")
set newname = "PrintWaitDetail-14936.xls"
Set sc = ftp.Store(newname,filestream)
Write "Length of file received: ",filestream.Size,!
If 'ftp.Logout() Write "Failed to logout",!



  • 0
  • 0
  • 197
  • 1
  • 2


Are you pointing the filestream to the correct file : is there any data in the filestream (you are using \Temp\GaganTest : it will use the same drive as the one where your database is located, also no extension is mentioned)

You can set a timeout (Set ftp.Timeout = 100) if the ftp server times out when uploading big files.

The file size will not effect your cache.dat size.

Hello Gagan,

Have you checked the value in sc from ftp.Store?

Also at that point you can check the values in ftp.ReturnCode and ftp.ReturnMessage for more details on the failure. 

This is also assuming that the status from ftp.Connect is ok and ftp.Connected is true.