Skip to content

DevExpress-Examples/asp-net-core-file-manager-connect-to-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Manager for ASP.NET Core - How to connect to a database

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.

Implementation Details

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.

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());
}

Files to Review

About

Get data from a database in the File Manager or implement custom processing logic.

Topics

Resources

License

Stars

Watchers

Forks