What is the whole process in order to connect to FTP server and exchange data using Genexus?
Asked
Active
Viewed 190 times
-1
-
Welcome to stack overflow! It would be easier to help if you **Search, and research** before asking a question here. Take a look at [How do I ask a good question](https://stackoverflow.com/help/how-to-ask) for more details. – Example person Jan 22 '22 at 09:02
1 Answers
-1
You can use SFTP Module. Documentation https://wiki.genexus.com/commwiki/servlet/wiki?45274,GeneXus+FTPS+Module
Here is some code:
//Knowledge Manager / Manage Module References / GenexusFTPS Module
//GX16U8 Module SFTP, SecurityAPICommons //&SftpOptions //SDT SftpOtptions
&SftpOptions.Host = !"172.16.4.5"
&SftpOptions.User = !"dummyuser"
&SftpOptions.Port = 22
&SftpOptions.Password = !"dumypass"
&SftpOptions.AllowHostKeyChecking = true
&SftpOptions.KeyPath = !"C:\Temp\keys\private_key.pem"
&SftpOptions.KeyPassword= !"dummykeypass"
&SftpOptions.KnownHostsPath = !"C:\Temp\known_hosts"
If &SftpClient.Connect( &SftpOptions)
If &SftpClient.Put( !"C:\temp\testfile.txt", "/sftptest")
Else
If &SftpClient.HasError()
msg( !"Error. Code: " + &SftpClient.GetErrorCode() + !"Description: " + &SftpClient.GetErrorDescription())
Endif
Endif
Else
If &SftpClient.HasError()
msg( !"Error. Code: " + &SftpClient.GetErrorCode() + !"Description: " + &SftpClient.GetErrorDescription())
Endif
Endif
&SftpClient.Disconnect()

Osvaldo
- 1
- 1
-
SFTP is not FTP. You have posted documentation for FTP(S) module, but code for SFTP. – Martin Prikryl Jan 11 '22 at 19:16