Closed tperiz closed 5 years ago
You can register you FTP command (derived from FtpCommandHandler
) via dependency injection. This will allow you to implement your own FTP command. The IFtpCommandHandlerExtension
implementations are meant as extensions to an existing command like - for example - OPTS UTF8
where the UTF8
is an extension to the OPTS
command.
The FTP commands are dispatched by FtpConnection.ProcessMessage
. This would be the point where you can (probably) implement interceptors.
I'll leave this issue open, because some kind of middlewares would be nice to have in the future.
I am also using FubarFTP server as a 'fake' ftp server. I took a different approach and simply wrote an alternative FileSystem, which was easier than expected. Now I can download on-the-fly generated files, and upload files and process them as if they were uploaded to an API (eg, do active processing after the upload is complete). Basically, this gives full control which was what I needed as really everything is fake.
This approach does not require any changes in Fubar codebase. Note that I am not using any of the default storage mechanisms.
Maybe this can also work for you, or it could be overkill.
There are now two "middleware" pipelines in 3.0.0-rc.3:
IFtpMiddleware
that gets executed between reading the command from the client and dispatching the command to the command handlerIFtpCommandMiddleware
which gets executed between the command dispatcher and the execution by the FTP command handlerThe former can be seen as a "request middleware" before "routing" (read: finding the correct command handler) while the latter is some kind of "command execution middleware".
The IFtpCommandMiddleware
is used by the sample (TestFtpServer
) to set the effective user and group IDs for file system accesses when run under Unix-style operating systems.
You should be able to use both middlewares for your kind of problem.
I'm using this library to setup a "fake" FTP server. I need to call my API every time a file is uploaded. I've noticed there is a
FtpCommandHandlerExtension
abstract class, however I couldn't managed to find an extension point where I could register my handlers. I've searched and it doesn't seem that you support middleware/handlers/interceptors. Is this correct? If so, where should I start looking in the sources to implement this myself?