nocobase-drive
它能做什么
这项技能配置 NocoBase 3 应用中的文件存储,涵盖本地文件夹、兼容 S3 的服务以及 Aliyun OSS。适合负责上传和存储设置的开发者。
适用场景
- ✓当你需要更改 NocoBase 应用上传文件的存储位置时。
- ✓当你想把应用连接到 S3 或 Aliyun OSS 存储时。
- ✓当你需要修复存储网址或文件操作的配置方式时。
技能链接
https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/drive/skills/nocobase-drive/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我把 NocoBase 应用的上传文件改为存储到 S3 存储桶中,而不是保存在本地磁盘上。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会修改存储配置,并根据存储类型选择合适的驱动程序。然后检查文件操作,以及应用生成的网址。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
File storage with NocoBase Drive
Use @nocobase/drive for storage operations. It wraps Flydrive with application configuration and a native Aliyun OSS driver. Choose the relevant reference before changing a disk:
| Storage | Driver | Read |
|---|---|---|
| A local or mounted filesystem | fs |
Filesystem configuration, paths, and URLs |
| Amazon S3 or an S3-compatible service | s3 |
S3 configuration, credentials, and ACLs |
| Native Aliyun OSS with access keys or an ECS RAM role | oss |
OSS configuration, credentials, and networking |
| An application-owned or third-party Flydrive driver | Factory function | Custom driver factories |
Configuration and application integration
Configure default and disks in server/config/drive.ts; config.yml can override serializable object options. A disk name is the key in disks, while driver selects an implementation. For example, local: { driver: 'fs', ... } is selected by drive.use('local'). default must name an entry in disks. Objects and synchronous factories can coexist; no separate services configuration or driver registry is required.
Keep the application's existing DriveProvider and import driveManagerToken from @nocobase/app-server/drive. In server code that already has an application instance:
import { driveManagerToken } from '@nocobase/app-server/drive';
const drive = app.container.resolve(driveManagerToken);
const disk = drive.use();
await disk.put('reports/example.txt', 'Example report');
const contents = await disk.get('reports/example.txt');
Use drive.use(name) to select another disk. Pass storage keys relative to that disk, such as reports/example.txt; do not pass an absolute filesystem path, a URL, or a pre-encoded key. The manager creates disks on first use and caches successful creation. Resolve the shared manager instead of constructing one per request.
File Repository selects these same disks by name. Use the installed File plugin for file records, Repository upload/download operations, and their permissions. Direct Drive operations do not create File Repository records or perform its authorization checks. Changing the default disk does not move stored objects or rewrite existing records.
Boundaries and verification
visibility does not itself guarantee HTTP access or isolation. Filesystem serving and object storage policies determine actual access; generating a public URL does not grant permission to a private object. Read the selected driver's URL behavior before exposing a link.
Release artifact storage needs serializable configuration. Custom factories are rejected when selected by releases.artifact.disk. Named artifact references currently accept private fs and s3 objects; use the complete OSS object directly under releases.artifact or host.artifact for OSS, as the OSS guide describes.
For standalone use, call prepareDriveStorage(config) before createDriveManager(config) when filesystem directory preparation is needed. The application Provider already performs preparation. Tests can supply createDriveManager(config, { fakes: { location } }) and use Flydrive's fake()/restore(); fakes verify application behavior without proving remote credentials, ACLs, or network access.
Verify a configuration change with a write, read or streamed download, and deletion under a disposable key. Check public or signed links from the intended client's network when the feature uses them. Report whether verification used local storage, fakes, or the real remote service. For custom drivers, also verify lazy creation and repeated use through the shared manager.
常见问题
这项技能涵盖上传权限吗?
不涵盖。文件集合和上传权限属于 File 插件。
我能使用未列出的存储类型吗?
可以。技能涵盖用于其他存储服务的自定义驱动工厂。
它涵盖存储凭据吗?
涵盖。它说明了每种存储类型的存储凭据如何配置。
详情
作者的原始描述
Configure and use file storage with @nocobase/drive in NocoBase 3 applications, including local filesystem, S3-compatible storage, native Aliyun OSS, and custom driver factories. Use when changing drive configuration, storage credentials, file operations, or storage URLs. File Repository collections and upload permissions belong to the File plugin.
repo: nocobase/nocobase
热度
- GitHub 星标
- 25k
- 排名
- #10084
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
nocobase-app-development
25k帮你的智能体为完整的 NocoBase 3 业务应用构建页面、路由、数据、权限和测试。
shadcn
25k帮你的智能体在 Web 项目中查找、添加、修复和美化 shadcn/ui 组件,并使用其官方文档和注册表。
nocobase-app-plugin-development
25k帮你的智能体在现有应用中创建和维护 NocoBase 3 插件,包括服务端、客户端、数据库和注册部分。
nocobase-app-upgrade
25k帮你的智能体把 NocoBase 应用升级到较新的模板版本,引入模板的更改,同时保留你自己的工作。