Possibility to catch the beggining of file transfer.

0 votes
asked Apr 25, 2018 by dmitry.petrishin (400 points)

Hello, is there a possibility in rebex sftp server of catching the beginning of file transfer?


Applies to: Rebex SFTP

1 Answer

0 votes
answered Apr 26, 2018 by Lukas Pokorny (128,250 points)
selected Apr 28, 2018 by dmitry.petrishin
Best answer

The most simple way would be to utilize the PathAccessAuthorization event to detect opening of a file for writing:

var server = new FileServer();
server.PathAccessAuthorization += (sender, args) =>
    if (args.Action == FileServerAction.OpenFile && args.RequestedOperations.HasFlag(FileSystemOperation.Write))
        Console.WriteLine("Opening {0} for writing.", args.FullPath);

An alternative would be to use a customized file system provider, but that seems to complex if all you need is to detect that a file has been opened for writing.

commented Apr 28, 2018 by dmitry.petrishin (400 points)
Thanks for answer!
No, it's not so simple, I don't need to use machine's file system. I need to use sftp server as middleware of file transporting. So I need to catch the stream and direct it to different remote server. How do you think what would be the best way to do that? Custom file system?
commented Apr 29, 2018 by renestein (4,390 points)
@dmitry.petrishin: Please, see my answer for your follow-up question  http://forum.rebex.net/8366/how-to-open-filenode-in-stream-for-further-transition