Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » FtpClient equivalent for SFTP
Re: FtpClient equivalent for SFTP [message #60459 is a reply to message #60454] Sat, 10 February 2024 19:30 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1226
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


 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Shot my leg again...
Next Topic: Linux Fedora 39
Goto Forum:
  


Current Time: Mon Aug 25 20:02:19 CEST 2025

Total time taken to generate the page: 0.05205 seconds