Question Gagan Kaushik · Aug 14, 2019

upload file to FTP

Hi

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",!

Regards

Gagan

Comments

Danny Wijnschenk · Aug 14, 2019

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.

0
Jeremy Klein · Aug 14, 2019

What is displayed from the following line:
Write "Length of file received: ",filestream.Size,!

If filestream.Size is 0 then you are not linking to the file.

0
David Underhill · Aug 20, 2019

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.

0