Best way to determine if file operation is upload or download in SFTPServer?

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Best way to determine if file operation is upload or download in SFTPServer?

Post by snorkel » Tue 01 Mar 2016 16:59

Hi,
I have the openfile event set and I used the default openfile event as a template.
My question is what would be the best way to determine if the file open is for upload or download?
Is checking if blockmode is bmRead or bmwrite sufficient?

I want to raise erPermissionDenied if the user does not have Stor or Retr permissions as stored in my authentication DB.

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

Re: Best way to determine if file operation is upload or download in SFTPServer?

Post by ViktorV » Wed 02 Mar 2016 15:51

To define upload/download operation mode, you should handle the OpenAttributes.Mode property in the TScSFTPServer.OnOpenFile event handler. For example:

Code: Select all

  if OpenAttributes.Mode in [fmOpenExisting] then
    OperationMode := 'Download'
  else
    OperationMode := 'Upload';

Post Reply