Page 1 of 1

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

Posted: Tue 01 Mar 2016 16:59
by snorkel
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.

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

Posted: Wed 02 Mar 2016 15:51
by ViktorV
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';