syncfusion-blazor-file-manager
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Syncfusion Blazor FileManager
实现Syncfusion Blazor FileManager组件
When to Use This Skill
适用场景
Use this skill when you need to:
- Create a file management interface - Build web applications for browsing, uploading, downloading, and managing files
- Set up cloud storage integration - Connect to Azure Blob Storage, Amazon S3, Google Drive, SharePoint, or Firebase
- Implement file operations - Enable users to create, delete, rename, copy, move, search files and folders
- Handle large file sets - Display thousands of files with virtualization and pagination
- Customize the UI - Tailor toolbar, context menu, views, and navigation to your needs
- Add drag-and-drop functionality - Allow users to drag and drop files for upload or organization
- Build accessible file systems - Provide WCAG-compliant file management with keyboard navigation
- Handle complex workflows - Implement custom sorting, filtering, previewing, and multi-provider scenarios
在以下场景中可使用该技能:
- 创建文件管理界面 - 构建用于浏览、上传、下载和管理文件的Web应用
- 搭建云存储集成 - 连接Azure Blob Storage、Amazon S3、Google Drive、SharePoint或Firebase
- 实现文件操作功能 - 支持用户创建、删除、重命名、复制、移动、搜索文件和文件夹
- 处理大规模文件集 - 通过虚拟化和分页展示数千个文件
- 自定义UI界面 - 根据需求定制工具栏、上下文菜单、视图模式和导航栏
- 添加拖拽功能 - 允许用户通过拖拽方式上传或整理文件
- 构建无障碍文件系统 - 提供符合WCAG标准的文件管理功能,支持键盘导航
- 处理复杂工作流 - 实现自定义排序、筛选、预览以及多服务商集成场景
Component Overview
组件概述
The Syncfusion Blazor FileManager is a comprehensive component for file and folder management. It provides:
- Multiple file operations: Read, Create, Delete, Rename, Search, Copy, Move, Upload, Download, Get Details, GetSelectedFiles
- Flexible data binding: AJAX settings, list objects, or injected services
- Rich events system: 20+ events including PageChanging/PageChanged for pagination
- Multiple UI customizations: Toolbar, context menu, view modes (Details, LargeIcons), NavigationPaneTemplate
- File preview capabilities: ShowThumbnail property for image and file previews
- Cloud provider support: Physical files, Azure, AWS S3, Google Drive, SharePoint, Firebase, SQL, FTP
- Advanced features: Virtualization, pagination with events, drag-and-drop, custom filtering, sorting, accessibility
- Layout management: RefreshLayoutAsync for dynamic resizing and nested component scenarios
- High performance: Handles large file sets with virtualization and lazy loading
Syncfusion Blazor FileManager是一款功能全面的文件与文件夹管理组件,具备以下特性:
- 多类文件操作:读取、创建、删除、重命名、搜索、复制、移动、上传、下载、获取详情、获取已选文件
- 灵活的数据绑定:AJAX配置、列表对象或注入式服务
- 丰富的事件系统:20+种事件,包括分页相关的PageChanging/PageChanged事件
- 多样化UI自定义:工具栏、上下文菜单、视图模式(详情视图、大图标视图)、NavigationPaneTemplate
- 文件预览能力:通过ShowThumbnail属性实现图片和文件预览
- 多云服务商支持:本地文件系统、Azure、AWS S3、Google Drive、SharePoint、Firebase、SQL、FTP
- 高级功能:虚拟化、带事件的分页、拖拽、自定义筛选与排序、无障碍访问
- 布局管理:使用RefreshLayoutAsync实现动态调整大小和嵌套组件场景
- 高性能表现:通过虚拟化和懒加载处理大规模文件集
Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation for Web App, Server App, WASM App, and MAUI App
- NuGet package setup and service registration
- Basic component initialization and AJAX configuration
- File provider setup and wwwroot configuration
- First file manager instance in 5 minutes
📄 阅读文档:references/getting-started.md
- Web应用、Server应用、WASM应用和MAUI应用的安装步骤
- NuGet包配置与服务注册
- 基础组件初始化与AJAX配置
- 文件提供程序设置与wwwroot配置
- 5分钟快速搭建首个FileManager实例
File Operations
文件操作
📄 Read: references/file-operations.md
- 11 core operations: Read, Create, Delete, Rename, Search, Details, Copy, Move, Upload, Download, GetImage
- Request/response data structures and parameters
- Operation examples with code from documentation
- Public methods: ,
DownloadFilesAsync(selectedItems)GetSelectedFiles() - File preview capabilities with property
ShowThumbnail - Sorting functionality with SortBy and SortOrder properties
📄 阅读文档:references/file-operations.md
- 11项核心操作:读取、创建、删除、重命名、搜索、详情、复制、移动、上传、下载、获取图片
- 请求/响应的数据结构与参数
- 带文档示例代码的操作演示
- 公开方法:、
DownloadFilesAsync(selectedItems)GetSelectedFiles() - 基于属性的文件预览能力
ShowThumbnail - 基于SortBy和SortOrder属性的排序功能
Data Binding Patterns
数据绑定模式
📄 Read: references/data-binding.md
- AjaxSettings for remote data binding
- List objects with local data and OnRead event
- Injected service pattern for complex scenarios
- FileManagerDirectoryContent structure
- When to use each binding method
📄 阅读文档:references/data-binding.md
- 用于远程数据绑定的AjaxSettings
- 结合本地数据与OnRead事件的列表对象
- 适用于复杂场景的注入式服务模式
- FileManagerDirectoryContent数据结构
- 各类绑定方式的适用场景
Events and Callbacks
事件与回调
📄 Read: references/events-and-callbacks.md
- 20+ file manager events with complete signatures
- Event lifecycle and timing
- Common event handler patterns
- BeforeDownload, BeforeImageLoad, OnFileOpen events
- ItemsDeleting, ItemsDeleted, FolderCreating, FolderCreated events
- Searching, Searched, ItemRenaming, ItemRenamed events
📄 阅读文档:references/events-and-callbacks.md
- 20+种FileManager事件及完整签名
- 事件生命周期与触发时机
- 通用事件处理模式
- BeforeDownload、BeforeImageLoad、OnFileOpen事件
- ItemsDeleting、ItemsDeleted、FolderCreating、FolderCreated事件
- Searching、Searched、ItemRenaming、ItemRenamed事件
Customization and UI
自定义与UI配置
📄 Read: references/customization.md
- Toolbar customization and item configuration
- Context menu customization
- View modes: Details View, LargeIcons View
- Navigation items customization with NavigationPaneTemplate
- Custom navigation pane templates with icons and metadata
- Styling and CSS customization
- Appearance and theme configuration
📄 阅读文档:references/customization.md
- 工具栏自定义与项配置
- 上下文菜单自定义
- 视图模式:详情视图、大图标视图
- 通过NavigationPaneTemplate自定义导航项
- 带图标和元数据的自定义导航面板模板
- 样式与CSS自定义
- 外观与主题配置
File Providers and Storage
文件提供程序与存储
📄 Read: references/file-providers.md
- Physical file provider (local file system)
- Azure Blob Storage configuration
- Amazon S3 cloud provider
- Google Drive integration
- SharePoint Online provider
- Firebase Real-time Database
- SQL Database provider
- FTP (File Transfer Protocol) provider
📄 阅读文档:references/file-providers.md
- 物理文件提供程序(本地文件系统)
- Azure Blob Storage配置
- Amazon S3云提供程序
- Google Drive集成
- SharePoint Online提供程序
- Firebase实时数据库
- SQL数据库提供程序
- FTP(文件传输协议)提供程序
Upload and Download
上传与下载
📄 Read: references/upload-download.md
- File upload configuration and events
- Directory upload (folder upload)
- File download with single and ZIP support
- Large file handling
- Upload progress tracking
- Download prevention and validation
- BeforeDownload event for custom logic
📄 阅读文档:references/upload-download.md
- 文件上传配置与事件
- 目录上传(文件夹上传)
- 支持单个文件和ZIP压缩包的下载功能
- 大文件处理
- 上传进度跟踪
- 下载限制与验证
- 用于自定义逻辑的BeforeDownload事件
Advanced Features
高级功能
📄 Read: references/advanced-features.md
- Virtualization for large file sets
- Pagination configuration with PageChanging and PageChanged events
- Drag and drop functionality
- Restrict drag-and-drop upload
- Custom filtering and search
- Nested items handling with RefreshLayoutAsync method
- Component integration in dialogs and containers
- Accessibility features (WCAG compliance)
- Keyboard navigation support
- Multiple file selection
📄 阅读文档:references/advanced-features.md
- 针对大规模文件集的虚拟化
- 结合PageChanging和PageChanged事件的分页配置
- 拖拽功能
- 限制拖拽上传
- 自定义筛选与搜索
- 使用RefreshLayoutAsync方法处理嵌套项
- 在对话框和容器中集成组件
- 无障碍访问功能(符合WCAG标准)
- 键盘导航支持
- 多文件选择
Quick Start Example
快速入门示例
razor
@using Syncfusion.Blazor.FileManager
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/FileManager/FileOperations"
UploadUrl="/api/FileManager/Upload"
DownloadUrl="/api/FileManager/Download"
GetImageUrl="/api/FileManager/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>Server-side setup (Program.cs):
csharp
using Syncfusion.Blazor;
builder.Services.AddSyncfusionBlazor();
builder.Services.AddControllers();
app.UseRouting();
app.MapControllers();HTML setup (App.razor):
html
<head>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
<body>
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
</body>razor
@using Syncfusion.Blazor.FileManager
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/FileManager/FileOperations"
UploadUrl="/api/FileManager/Upload"
DownloadUrl="/api/FileManager/Download"
GetImageUrl="/api/FileManager/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>服务端配置(Program.cs):
csharp
using Syncfusion.Blazor;
builder.Services.AddSyncfusionBlazor();
builder.Services.AddControllers();
app.UseRouting();
app.MapControllers();HTML配置(App.razor):
html
<head>
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
<body>
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
</body>Common Patterns
常见实现模式
Pattern 1: Local Data with OnRead Event
模式1:结合OnRead事件的本地数据绑定
razor
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent" OnRead="OnReadAsync"></FileManagerEvents>
</SfFileManager>
@code {
private async Task OnReadAsync(ReadEventArgs<FileManagerDirectoryContent> args)
{
// Load data from your service
var response = await YourService.GetFilesAsync(args.Path);
args.Response = response;
}
}razor
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent" OnRead="OnReadAsync"></FileManagerEvents>
</SfFileManager>
@code {
private async Task OnReadAsync(ReadEventArgs<FileManagerDirectoryContent> args)
{
// 从服务加载数据
var response = await YourService.GetFilesAsync(args.Path);
args.Response = response;
}
}Pattern 2: Cloud Storage with Azure Provider
模式2:结合Azure提供程序的云存储集成
razor
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/AzureProvider/FileOperations"
UploadUrl="/api/AzureProvider/Upload"
DownloadUrl="/api/AzureProvider/Download"
GetImageUrl="/api/AzureProvider/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>razor
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerAjaxSettings Url="/api/AzureProvider/FileOperations"
UploadUrl="/api/AzureProvider/Upload"
DownloadUrl="/api/AzureProvider/Download"
GetImageUrl="/api/AzureProvider/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>Pattern 3: Programmatic Download
模式3:程序化下载
razor
@ref="FileManager"
<SfButton OnClick="DownloadFiles">Download Selected</SfButton>
<SfFileManager @ref="FileManager" TValue="FileManagerDirectoryContent">
<!-- configuration -->
</SfFileManager>
@code {
SfFileManager<FileManagerDirectoryContent> FileManager;
public async Task DownloadFiles()
{
await FileManager.DownloadFilesAsync(FileManager.SelectedItems);
}
}razor
@ref="FileManager"
<SfButton OnClick="DownloadFiles">下载已选文件</SfButton>
<SfFileManager @ref="FileManager" TValue="FileManagerDirectoryContent">
<!-- 配置内容 -->
</SfFileManager>
@code {
SfFileManager<FileManagerDirectoryContent> FileManager;
public async Task DownloadFiles()
{
await FileManager.DownloadFilesAsync(FileManager.SelectedItems);
}
}Pattern 4: Custom Event Handling
模式4:自定义事件处理
razor
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent"
ItemsDeleting="OnItemsDeleting"
BeforeDownload="OnBeforeDownload">
</FileManagerEvents>
</SfFileManager>
@code {
public async Task OnItemsDeleting(ItemsDeleteEventArgs<FileManagerDirectoryContent> args)
{
// Validate before delete
if (args.Files.Count > 10)
{
args.Cancel = true;
}
}
public void OnBeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)
{
// Custom download logic
}
}razor
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent"
ItemsDeleting="OnItemsDeleting"
BeforeDownload="OnBeforeDownload">
</FileManagerEvents>
</SfFileManager>
@code {
public async Task OnItemsDeleting(ItemsDeleteEventArgs<FileManagerDirectoryContent> args)
{
// 删除前验证
if (args.Files.Count > 10)
{
args.Cancel = true;
}
}
public void OnBeforeDownload(BeforeDownloadEventArgs<FileManagerDirectoryContent> args)
{
// 自定义下载逻辑
}
}Key Properties
核心属性
| Property | Type | Default | Purpose |
|---|---|---|---|
| Generic | FileManagerDirectoryContent | Data model type |
| string | - | AJAX endpoint for file operations |
| string | - | Upload endpoint |
| string | - | Download endpoint |
| string | - | Image preview endpoint |
| string | Name | Sort field (Name, Size, DateModified, DateCreated) |
| SortOrder | Ascending | Sort direction (None, Ascending, Descending) |
| ViewType | LargeIcons | Display mode (Details, LargeIcons) |
| bool | false | Enable virtual scrolling for large datasets |
| string | - | Root directory path |
| bool | false | Show hidden files and folders |
| bool | false | Enable pagination support |
| int | 100 | Number of items per page |
| bool | false | Allow directory upload |
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| 泛型 | FileManagerDirectoryContent | 数据模型类型 |
| 字符串 | - | 文件操作的AJAX端点 |
| 字符串 | - | 上传端点 |
| 字符串 | - | 下载端点 |
| 字符串 | - | 图片预览端点 |
| 字符串 | Name | 排序字段(名称、大小、修改日期、创建日期) |
| SortOrder | Ascending | 排序方向(无、升序、降序) |
| ViewType | LargeIcons | 展示模式(详情、大图标) |
| 布尔值 | false | 为大规模数据集启用虚拟滚动 |
| 字符串 | - | 根目录路径 |
| 布尔值 | false | 显示隐藏文件和文件夹 |
| 布尔值 | false | 启用分页支持 |
| 整数 | 100 | 每页展示项数 |
| 布尔值 | false | 允许目录上传 |
Common Use Cases
常见应用场景
1. Internal Document Management
- Setup with physical file provider
- Use toolbar for CRUD operations
- Enable search and filtering
- Add event handlers for audit logging
2. Cloud-Based Team Collaboration
- Connect to Azure or AWS S3
- Enable drag-and-drop upload
- Add custom toolbar for sharing
- Implement access control via events
3. Media Library
- Enable image preview with GetImageUrl
- Use LargeIcons view for thumbnails
- Implement pagination for performance
- Add custom filtering by file type
4. Backup and Archive System
- Connect to multiple storage providers
- Enable download with compression
- Use virtualization for large datasets
- Add custom sorting and filtering
5. Public File Sharing Portal
- Restrict operations via event handlers
- Disable delete and rename
- Enable download and preview only
- Customize navigation and UI
1. 内部文档管理系统
- 使用物理文件提供程序搭建
- 利用工具栏实现CRUD操作
- 启用搜索与筛选功能
- 添加事件处理程序用于审计日志
2. 基于云的团队协作平台
- 连接Azure或AWS S3
- 启用拖拽上传
- 添加用于分享的自定义工具栏
- 通过事件实现访问控制
3. 媒体库系统
- 利用GetImageUrl启用图片预览
- 使用大图标视图展示缩略图
- 实现分页提升性能
- 添加按文件类型的自定义筛选
4. 备份与归档系统
- 连接多个存储提供程序
- 启用带压缩的下载功能
- 为大规模数据集使用虚拟化
- 添加自定义排序与筛选
5. 公共文件分享门户
- 通过事件处理程序限制操作权限
- 禁用删除和重命名功能
- 仅启用下载与预览
- 自定义导航与UI界面
Next Steps
后续步骤
- Choose your setup: Start with Getting Started for your platform
- Pick your data source: Read Data Binding Patterns to choose AJAX, local, or service
- Configure file operations: Check File Operations for available actions
- Handle events: Review Events and Callbacks for required handlers
- Customize UI: See Customization for toolbar and themes
- Choose storage: Select provider in File Providers
- 选择搭建方式:根据你的平台参考快速入门
- 选择数据源:阅读数据绑定模式以选择AJAX、本地数据或服务绑定
- 配置文件操作:查看文件操作了解可用操作
- 处理事件:参考事件与回调实现所需处理程序
- 自定义UI:查看自定义配置进行工具栏与主题设置
- 选择存储方案:在文件提供程序中选择合适的提供程序