Log uploads and downloads

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
mbillig02
Posts: 19
Joined: Sat 09 Feb 2019 23:16

Log uploads and downloads

Post by mbillig02 » Sat 09 Feb 2019 23:20

I did not see an example of logging uploads and downloads. Does someone have an example of how to do this?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Log uploads and downloads

Post by ViktorV » Mon 11 Feb 2019 12:26

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.

mbillig02
Posts: 19
Joined: Sat 09 Feb 2019 23:16

Re: Log uploads and downloads

Post by mbillig02 » Mon 11 Feb 2019 15:02

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..

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Log uploads and downloads

Post by ViktorV » Wed 13 Feb 2019 11:51

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

mbillig02
Posts: 19
Joined: Sat 09 Feb 2019 23:16

Re: Log uploads and downloads

Post by mbillig02 » Wed 13 Feb 2019 17:30

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;

mbillig02
Posts: 19
Joined: Sat 09 Feb 2019 23:16

Re: Log uploads and downloads

Post by mbillig02 » Wed 13 Feb 2019 20:08

Is there any way to capture the commands being sent from the client? Example, PWD, CWD /, RETR TESTFILE.TXT, etc...

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Log uploads and downloads

Post by ViktorV » Fri 15 Feb 2019 11:49

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.

Post Reply