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 » Newbie corner » [Solved] SFTPBrowser example build failed (SFTPBrowser example buil error: error LNK2019: unresolved external symbol __imp_CertCloseStore referenced in function winstore_close)
Re: SFTPBrowser example build failed [message #61299 is a reply to message #61297] Fri, 20 December 2024 15:42 Go to previous messageGo to previous message
Scott_Huang is currently offline  Scott_Huang
Messages: 27
Registered: December 2024
Promising Member
Hi Oblivion,

Merry Christmas!

Actually I testing different size files before last post, including 1M, all failed and create 0 size file in SFTP server.
SFtpFileOut should have some bug in case some SFTP server not similar as your demo SFTP server.

Anyway, I have upgrade code with your hint as below, it can successful upload files and also show progress %:
void SFtpBrowser::Transfer(int opcode, const String src, const String& dest)
{
	SFtp worker(session);
	Progress pi(this, src);

	worker.WhenProgress = [&pi](int64 done, int64 total) {
		pi.SetText(Format(t_("%1:s of %2:s is transferred"), FormatFileSize(done),
		                  FormatFileSize(total)));
		return pi.SetCanceled(int(done), int(total));
	};
	pi.Create();
	switch(opcode) {
	case GET: {
		pi.Title(t_("Downloading ") << GetFileName(src));
		FileOut fout(dest);
		if(fout && !worker.LoadFile(fout, src))
			ErrorOK(DeQtf(worker.GetErrorDesc()));
		break;
	}
	case PUT: {
		pi.Title(t_("Uploading ") << GetFileName(src)); // Not for use, only for testing
		String s = LoadFile(src);

		if(auto h = worker.OpenWrite(dest); h) {

			/*			int n = worker.Put(h, ~s, s.GetLength());
			            RLOG(String() << "Uploaded: " << n << ", filesize: " << s.GetLength());
			            RDUMP(worker.IsError());
			            if(worker.IsError())
			                ErrorOK(DeQtf(worker.GetErrorDesc()));
			            worker.Close(h);*/

			int64 size = s.GetLength(), count = 0;
			if(settings.log)
				RLOG(Format("File size %d", size));
			int chunkSize = 1024 * 64, thisTimeSize = 0;
			worker.WhenProgress(0, size);
			while(!(count >= size)) {
				thisTimeSize = (int)min<int64>(size - count, chunkSize);
				if(settings.log)
					RLOG(Format("======= size %d, count %d, chunkSize %d, min %d", size, count,
					            chunkSize, thisTimeSize));
				int x = worker.Put(h, (~s) + count, thisTimeSize);
				count += x;
				if(settings.log)
					RLOG(String() << "This time should be uploaded: " << thisTimeSize
					              << ", Real uploaded: " << x << ", Current Accumulated Count:"
					              << count << ", total filesize: " << size);
				// RDUMP(worker.IsError());
				if(worker.WhenProgress(count, size)) {
					break;
				}

				if(worker.IsError()) {
					ErrorOK("Upload failed : " + DeQtf(worker.GetErrorDesc()));
					break;
				}
			}

			worker.Close(h);
			break;
		}
		else if(settings.log)
			RLOG("Couldn't open file: " << src << ", error: " << worker.GetErrorDesc());

		break;
	}
	}
	LoadDir();
}


You can consider this issue fixed.
But could you help improve it when you have time:

1. Any better way if compare to above? (I am new for UPP)
2. Enhance it to real multiple threads, above actually is single upload thread, quite slow if compare to 3rd party SFTP software.

3. Why stream way failed and we have switch to one time read file into String and then chunk write into SFTP?


Regards,
Scott Huang

[Updated on: Sat, 21 December 2024 04:44]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Latest U++ PDF version user guide to describe framework/tips/examples
Next Topic: The UPP looks good -> Opportunities to evolve to better support RPA & AI
Goto Forum:
  


Current Time: Tue Aug 05 14:43:58 CEST 2025

Total time taken to generate the page: 0.01103 seconds