0 votes
by (400 points)

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

Thanks.

Applies to: Rebex SFTP

1 Answer

0 votes
by (144k points)
selected by
 
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.

by (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?
by (5.1k 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
...