Help with simple file upload sequence
Posted: Wed  01 Dec 2010 06:55
				
				Hi,
I think this is just what I need to do a simple file upload to an SSH server.
I can get it all working with each event driven from buttons but I have some problems with the sequence and events to make it automatic.
My program needs to connect, upload a file, and disconnect, that's all.
Basically I do this, each fired from a form button and it works great:
ScSSHClient1.Connect;
ScSFTPClient1.Initialize;
ScSFTPClient1.UploadFile();
ScSFTPClient1.Disconnect;
ScSSHClient1.Disconnect;
To automate this I use the ScSSHClient1.AfterConnect event to fire the ScSFTPClient1.Initialize;
I was hoping to use the ScSFTPClient1.OnConnect to fire the UploadFile but here is where I think I an running into trouble, it is not AfterConnect, so within this OnConnect event I cant do anything as I assume I am not yet connected.
Also when uploading I know I can look for the second OnSuccess to disconnect but I dont want to use that because I want to be able to abort and disconnect everything if (for example) the upload file is not ready or has errors etc. So I can't rely on the OnSucces event to close it all down.
If I abort and try to disconnect the SSH from within the SFTP.OnConnect I get stuck in a loop.
I assume the SSH reconnectes when the SFTP.OnConnect event ends and that retriggers the SSH.AfterConnect, which in turn executes my SFTP.Initilize again and so on.
Any ideas how I can get this sequence to fire automatically and also have the option to abort the upload and disconnect if required?
BR
			I think this is just what I need to do a simple file upload to an SSH server.
I can get it all working with each event driven from buttons but I have some problems with the sequence and events to make it automatic.
My program needs to connect, upload a file, and disconnect, that's all.
Basically I do this, each fired from a form button and it works great:
ScSSHClient1.Connect;
ScSFTPClient1.Initialize;
ScSFTPClient1.UploadFile();
ScSFTPClient1.Disconnect;
ScSSHClient1.Disconnect;
To automate this I use the ScSSHClient1.AfterConnect event to fire the ScSFTPClient1.Initialize;
I was hoping to use the ScSFTPClient1.OnConnect to fire the UploadFile but here is where I think I an running into trouble, it is not AfterConnect, so within this OnConnect event I cant do anything as I assume I am not yet connected.
Also when uploading I know I can look for the second OnSuccess to disconnect but I dont want to use that because I want to be able to abort and disconnect everything if (for example) the upload file is not ready or has errors etc. So I can't rely on the OnSucces event to close it all down.
If I abort and try to disconnect the SSH from within the SFTP.OnConnect I get stuck in a loop.
I assume the SSH reconnectes when the SFTP.OnConnect event ends and that retriggers the SSH.AfterConnect, which in turn executes my SFTP.Initilize again and so on.
Any ideas how I can get this sequence to fire automatically and also have the option to abort the upload and disconnect if required?
BR