How to get files from FTP Server
Hello!
I'm trying to get files from FTP server. Bellow my code:
set ftp = ##class(%Net.FtpSession).%New()
set ftp.Timeout = 5
set host="speedtest.tele2.net"
set port = 21
If 'ftp.Connect(host,"USER","USER",port) Write ftp.ReturnMessage,! Quit sc
Write "Ftp server messsage:",!,ftp.ReturnMessage,!
Set stream=##class(%GlobalCharacterStream).%New()
If 'ftp.Binary() Write "Can not swap to binary mode",! Quit sc
Write "Mode now: ",ftp.Type,!
If 'ftp.Retrieve("512KB.zip",stream) Write "Failed to get file",! Quit sc
Write "Length of file received: ",stream.Size,!
If 'ftp.Logout() Write "Failed to logout",!
Quit ftp.Logout()
I'm getting error:
Unable to open connection to speedtest.tele2.net on port 21.