- name
- nocobase-drive
- description
- 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.
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:
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');