Question
prabakaran a · Apr 20, 2017

Cache FTP issue

Hi All,

         We can sent the file to FTP server using CMD prompt.

         When trying send file using cache FTP. it automatically logged out.

          While cache FTP access (read/write) FTP server it automatically logged out.

CODE:

S ftp=##class(%Net.FtpSession).%New() 
     S Server="test"
     S Username="test"
     S Password="test"
     I $L(Server)=0||($L(Username)=0)||($L(Password)=0) S Status="Invalid Credentials" Q Status 
     S ConnSt=ftp.Connect(Server,Username,Password)
     I 'ConnSt S Status="Couldn't Estabilish the FTP connection" Q Status
     ;
     ;Linking the file 
     D ftp.Binary()    
      S filestream=##class(%FileBinaryStream).%New()  
      S LinkSt=filestream.LinkToFile(File)  
      I 'LinkSt S Status="Couldn't Link to the ZIP file" G LOGOUT
      ;Storing the file to the FTP
      S FtpStoreName="TEST.ZIP"
      S SaveSt=ftp.Store(FtpStoreName,filestream)    ;This Step it automatically logout    
      I 'SaveSt S Status="Failed to move the ZIP file to the FTP Server" G LOGOUT

version : cache 16

Thanks,

Prabakaran A.

00
4 0 1 545
Log in or sign up to continue

Replies

Check that you have not lost connection just before the Store() method...

ftp.Connected

Also check the value of

ftp.ReturnMessage

just after the Store() method, if there was a failure then this would have something useful to go on.

Sean.