跳到正文
Skillpedia
API 与服务器(后端)25k · #10084

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/drive/skills/nocobase-drive/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能