> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # FilesystemProvider `FilesystemProvider` 是套件用來向 [`MastraEditor`](https://mastra.zisheng.pro/zh-HK/reference/editor/mastra-editor) 註冊檔案系統的介面。Editor 會在 Workspace hydrate 時呼叫 `createFilesystem(config)`,並以已儲存 [`StorageWorkspaceRef`](https://mastra.zisheng.pro/zh-HK/reference/editor/storage-workspace-ref) 檔案系統配置的 `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 檔案系統選擇器中顯示的簡短描述。 **configSchema** (`Record`): 描述 Provider 專屬配置的 JSON Schema。UI 會使用它呈現配置表單。 **createFilesystem** (`(config: TConfig) => WorkspaceFilesystem | Promise`): 從已儲存的配置建立執行階段 WorkspaceFilesystem 實例。在 Workspace hydrate 時呼叫。 ## 實作 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 }) }, } ``` 註冊後,管理員可在 inline Workspace 配置或已儲存的 [`StorageWorkspaceRef`](https://mastra.zisheng.pro/zh-HK/reference/editor/storage-workspace-ref) 中引用此 Provider。 ## 相關內容 - [Workspace](https://agent-builder.mastra.ai/workspace):概念及完整範例。 - [StorageWorkspaceRef](https://mastra.zisheng.pro/zh-HK/reference/editor/storage-workspace-ref):`createFilesystem` 使用的已儲存配置。 - [SandboxProvider](https://mastra.zisheng.pro/zh-HK/reference/editor/sandbox-provider):用於執行指令的同類 Provider。 - [MastraEditor 類別](https://mastra.zisheng.pro/zh-HK/reference/editor/mastra-editor):Provider registry。