|
|
Home » Community » Coffee corner » FtpClient equivalent for SFTP
|
Re: FtpClient equivalent for SFTP [message #60453 is a reply to message #60452] |
Wed, 07 February 2024 13:25   |
Oblivion
Messages: 1206 Registered: August 2007
|
Senior Contributor |
|
|
Hello Luigi,
SFtp class is part of SSH package (is in uppsrc/Core, it has its API doc as Topic++ and examples in the reference examples section (SshBasics & SFtpFileSel).
You cannot use SSH package with plain FTP protocol, as they are completely different.
However, there are also additional an alternative FTP class here, which is arguably more advanced than the default one in uppsrc.
If you need additional example on SSH and FTP, see the upp-components/examples section.
If you need any more help, let me know.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Wed, 07 February 2024 13:27] Report message to a moderator
|
|
|
|
Re: FtpClient equivalent for SFTP [message #60459 is a reply to message #60454] |
Sat, 10 February 2024 19:30   |
Oblivion
Messages: 1206 Registered: August 2007
|
Senior Contributor |
|
|
Hello Luigi,
Sorry I couldn't reply earlier.
There are several ways to transfer a file to a remote host.
One of the basic examples could be as follows:
#include <Core/Core.h>
#include <Core/SSH/SSH.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
SshSession session;
FileIn fi("/local/files/myfile");
if(fi && session.Compression().Connect("user:password@address:port_number")) {
SFtp sftp(session);
sftp.WhenProgress = [](int64 done,int64 total) { Cout() << done << " / " << total << "\n"; return false; };
if(!sftp.SaveFile("/remote/files/myfile", fi))
Cout() << "File transfer failed: " << sftp.GetErrorDesc() << "\n";
return;
}
if(session.IsError())
Cout() << session.GetErrorDesc() << "\n";
}
Note that this example code does not handle the private and public keys, or other mechanism but the examples I provided via the link of my first post can help you. Especially the SftpBrowser. It can open connections with public/private key, and upload files.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
|
|
|
|
Goto Forum:
Current Time: Mon May 12 03:31:15 CEST 2025
Total time taken to generate the page: 0.03632 seconds
|
|
|