Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)25k · #10084

nocobase-drive

Skill này làm gì

Skill này cấu hình lưu trữ tệp trong ứng dụng NocoBase 3, gồm thư mục cục bộ, dịch vụ tương thích S3 và Aliyun OSS. Skill dành cho lập trình viên xử lý tải tệp lên và cài đặt lưu trữ.

Khi nào nên dùng

  • ✓Khi bạn cần đổi nơi ứng dụng NocoBase lưu các tệp đã tải lên.
  • ✓Khi bạn muốn kết nối ứng dụng với bộ nhớ S3 hoặc Aliyun OSS.
  • ✓Khi bạn cần sửa cách cấu hình URL lưu trữ hoặc các thao tác với tệp.

Liên kết skill

https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/drive/skills/nocobase-drive/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/nocobase/nocobase/blob/v3-develop/packages/libs/drive/skills/nocobase-drive/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể thiết lập ứng dụng NocoBase của tôi để lưu tệp tải lên trong một bucket S3 thay vì ổ đĩa cục bộ không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI chỉnh sửa cấu hình lưu trữ và chọn driver phù hợp với loại lưu trữ. Sau đó nó kiểm tra các thao tác với tệp và URL mà ứng dụng tạo ra.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.

Câu hỏi thường gặp

Skill này có bao gồm quyền tải tệp lên không?

Không. Bộ sưu tập tệp và quyền tải lên thuộc về plugin File.

Tôi có thể dùng một loại lưu trữ không có trong danh sách không?

Có. Skill có đề cập đến factory driver tùy chỉnh cho các dịch vụ lưu trữ khác.

Skill có đề cập đến thông tin xác thực lưu trữ không?

Có. Skill giải thích cách cấu hình thông tin xác thực cho từng loại lưu trữ.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
25k
Vị trí xếp hạng
#10084
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự