Search code examples
pythonsftpparamiko

Firing an event on SFTP file receipt completion with Paramiko SFTP server


If I use the Paramiko server for SFTP, is it possible to fire an event when a file is received?

I have read the reference manual and looked at some example code and cannot see any examples.


Solution

  • You need to override the SFTPHandle.close method.

    Though it is called, whenever any kind of work with the file is finished. Including for example a download.

    If you need to filter out uploads only, you need to add more checks. Like verify that the file was originally opened with a write access. See the flags argument to the SFTPHandle constructor.