Page 1 of 1

Log uploads and downloads

Posted: Sat 09 Feb 2019 23:20
by mbillig02
I did not see an example of logging uploads and downloads. Does someone have an example of how to do this?

Re: Log uploads and downloads

Posted: Mon 11 Feb 2019 12:26
by ViktorV
To solve the problem, you can use the following recommendations:
- If you upload (download) a file using the TScSFTPClient.UploadFile method (TScSFTPClient.DownloadFile), the execution of this method without errors is a sign of the correct file upload to the server (downloading the file from the server).
- to get information about executing the procedures for loading (downloading) a file, you can handle the TScSFTPClient.OnData and TScSFTPClient.AfterWriteData events. The OnData event is raised only on downloading a file from SFTP server. To process sending data you can use the AfterWriteData event.
Also, to determine the end of file loading to the server, you can use the event handler TScSFTPClient.OnSuccess when Operation = opClosingHandle. This event is initiated when Operation = opClosingHandle, is initiated when the data transfer is successfully completed.

Re: Log uploads and downloads

Posted: Mon 11 Feb 2019 15:02
by mbillig02
I apologize I left out one important thing. I am referencing the server component (ScSFTPServer). Are there any events that I can use the report what the user is doing? Uploading, downloading, etc..

Re: Log uploads and downloads

Posted: Wed 13 Feb 2019 11:51
by ViktorV
To solve your problem, you can use the required event handlers of the TScSFTPServer component.
For example, use the TScSFTPServer.OnWriteFile event handlers when performing the Upload operation, or the TScSFTPServer.OnReadFile event handlers when performing the DownloadFile or ReadFile operations, etc.
For more information about these events, please visit the SecureBridge help: https://devart.com/sbridge/docs/tscsftp ... events.htm

Re: Log uploads and downloads

Posted: Wed 13 Feb 2019 17:30
by mbillig02
Thank you for your help. I was not calling the "default" so it looked like it was stuck.

procedure TMainForm.ScSFTPServerOpenDirectory(Sender: TObject;
SFTPSessionInfo: TScSFTPSessionInfo; const Path: string; out Data: TObject;
var Error: TScSFTPError);
var
TmpStr: String;
begin
TmpStr := 'Open directory -> ' + ScSFTPServer.GetFullPath(SFTPSessionInfo, Path);
WriteLog(TmpStr, SFTPSessionInfo.Client);
ScSFTPServer.DefaultOpenDirectory(SFTPSessionInfo, Path, Data, Error);
end;

Re: Log uploads and downloads

Posted: Wed 13 Feb 2019 20:08
by mbillig02
Is there any way to capture the commands being sent from the client? Example, PWD, CWD /, RETR TESTFILE.TXT, etc...

Re: Log uploads and downloads

Posted: Fri 15 Feb 2019 11:49
by ViktorV
The SFTP protocol sends the codes of the commands, not their text representation. Thus, you can use all event processors of the ScSFTPServer component for more comprehensive logging.