0

I'm currently developing an ftp server using pyftpdlib by giampaolo. I've been struggling since I need to process stuff when the server receive the RETR commnand before sending a given file.

My question is, is there any form of implementing a callback or tweaking the source so I can do such validation over a file before it is sent, and if so how would I implement it?

jevisan
  • 23
  • 4

1 Answers1

1

You can simply override ftp_RETR method:

from pyftpdlib.handlers import FTPHandler

class Handler(FTPHandler):

    def ftp_RETR(self, file):
        if not condition:
            self.respond("500 sorry!")
        else:
            super(Handler, self).ftp_RETR(file)
Giampaolo RodolĂ 
  • 12,488
  • 6
  • 68
  • 60