FileSystemProvider: add option to handle file move with a dedicated method instead of GetContent/SaveContent
We use the FileServer library to provide an SFTP layer on top of our cloud storage solution. In our use case we need to log every action that users perform on files and folders.
The problem with current implementation is that a file move is treated - and thus logged - as a download followed by an upload.
It would be nice to have a dedicated method for file/folder move instead.
We already have a dedicated method for file/folder move. See the comment for details.
-
Adminmartin.vobr (Admin, Rebex) commented
Thanks for the suggestion.
Actually, ReadWriteFileSystemProvider, which is probably the base class for your custom provider, already has protected virtual Move method.
You can override this method and log everything what you need.
Simple implementation:protected override NodeBase Move(NodeBase toBeMovedNode, DirectoryNode targetDirectory)
{
Log.Write(...);
return base.Move(toBeMovedNode, targetDirectory);
}Also notifier associated with your file system provider publish MovePreview, MoveSurrogate and MoveCompleted events.
using Rebex.IO.FileSystem;
using Rebex.IO.FileSystem.Notifications;
….
var customFsProvider = new MyCustomProvider;
var notifier = customFsProvider.GetFileSystemNotifier();
notifier.MovePreview += logFileMoveprivate static void logFileMove(object sender, PreviewCopyMoveEventArgs e)
{
//log move
}Documentation links:
https://api.rebex.net/##RebexTotalPack.chm/Html/E_Rebex_IO_FileSystem_Notifications_FileSystemNotifier_MovePreview.htm
https://api.rebex.net/##RebexTotalPack.chm/Html/E_Rebex_IO_FileSystem_Notifications_FileSystemNotifier_MoveSurrogate.htm
https://api.rebex.net/##RebexTotalPack.chm/Html/E_Rebex_IO_FileSystem_Notifications_FileSystemNotifier_MoveCompleted.htmIf you have any further questions, drop an email to support@rebex.net or post a new question on the Rebex forum: http://forum.rebex.net/questions