> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # FilesystemProvider `FilesystemProvider` 是包用来向 [`MastraEditor`](https://mastra.zisheng.pro/reference/editor/mastra-editor) 注册 filesystem 的接口。Editor 会在 Workspace 实例化时调用 `createFilesystem(config)`,并使用已存储 [`StorageWorkspaceRef`](https://mastra.zisheng.pro/reference/editor/storage-workspace-ref) filesystem 配置中的 `provider` id 作为查找键。 内置 `local` filesystem Provider 会自动注册。外部 Provider(例如 S3 或 GCS)通过 `MastraEditorConfig.filesystems` 提供。 ## 使用示例 ```typescript import { MastraEditor } from '@mastra/editor' import { s3FilesystemProvider } from '@mastra/s3' new MastraEditor({ filesystems: { [s3FilesystemProvider.id]: s3FilesystemProvider, }, }) ``` ## 属性 **id** (`string`): 唯一的 Provider 标识符(例如 "local"、"s3")。必须与使用此 Provider 的每个已存储 Workspace 上的 StorageFilesystemConfig.provider 一致。 **name** (`string`): 在 UI 中显示的易读名称。 **description** (`string`): Workspace filesystem 选择器中显示的简短描述。 **configSchema** (`Record`): 描述 Provider 专用配置的 JSON Schema。UI 使用它渲染配置表单。 **createFilesystem** (`(config: TConfig) => WorkspaceFilesystem | Promise`): 根据已存储配置创建运行时 WorkspaceFilesystem 实例。在 Workspace 实例化时调用。 ## 实现 Provider ```typescript import type { FilesystemProvider, WorkspaceFilesystem } from '@mastra/core/editor' export const myFilesystemProvider: FilesystemProvider<{ bucket: string; region: string }> = { id: 'my-fs', name: 'My Filesystem', description: 'Object-store-backed filesystem.', configSchema: { type: 'object', required: ['bucket', 'region'], properties: { bucket: { type: 'string' }, region: { type: 'string' }, }, }, async createFilesystem(config): Promise { return createMyFilesystem({ bucket: config.bucket, region: config.region }) }, } ``` 注册后,管理员可以从内联 Workspace 配置或已存储的 [`StorageWorkspaceRef`](https://mastra.zisheng.pro/reference/editor/storage-workspace-ref) 中引用该 Provider。 ## 相关内容 - [Workspace](https://agent-builder.mastra.ai/workspace):概念和完整示例。 - [StorageWorkspaceRef](https://mastra.zisheng.pro/reference/editor/storage-workspace-ref):由 `createFilesystem` 使用的已存储配置。 - [SandboxProvider](https://mastra.zisheng.pro/reference/editor/sandbox-provider):用于执行命令的同级 Provider。 - [MastraEditor 类](https://mastra.zisheng.pro/reference/editor/mastra-editor):Provider 注册表。