This example demonstrates how to get data from a database and display it in the File Manager or implement custom processing logic. To implement server interaction with a file system, pass a class that uses file management interfaces to the FileSystemProvider property.
1. Add the FileManager control to your page and configure it according to your requirements.
2. Set the Url
option so that it points to your API controller.
@(Html.DevExtreme().FileManager()
.CurrentPath("Documents/Reports")
.FileSystemProvider(provider => provider.Remote()
.Url(Url.RouteUrl("FileManagerApi")))
3. Specify File Manager Permissions according to your requirements.
4. Implement required file management interfaces.
- If you want only to display files and folders, implement IFileSystemItemLoader.
- If you want to copy, move, and delete items - implement IFileSystemItemEditor.
You can find a full implementation example in the DbFileProvider.cs file.
5. Create a method in your API Controller that will handle File Manager operations. Use your custom provider there.
public FileManagerApiController(DbFileProvider dbFileProvider) {
_dbFileProvider = dbFileProvider ?? throw new ArgumentNullException(nameof(dbFileProvider));
}
DbFileProvider _dbFileProvider { get; }
[Route("api/file-manager-db", Name = "FileManagerApi")]
public IActionResult Process(FileSystemCommand command, string arguments) {
var config = new FileSystemConfiguration {
Request = Request,
FileSystemProvider = _dbFileProvider,
AllowCopy = true,
AllowCreate = true,
AllowMove = true,
AllowDelete = true,
AllowRename = true,
AllowedFileExtensions = new string[0]
};
var processor = new FileSystemCommandProcessor(config);
var result = processor.Execute(command, arguments);
return Ok(result.GetClientCommandResult());
}