@ arkstack/ 文件系统
Arkstack 的文件系统模块,为框架提供共享文件存储和文件系统实用化.
自定义驱动程序
@ arkstack/ filesystem 允许您配置并使用自定义的存储驱动程序 .
Cloudinary FileDriver.ts (英语)
import type { DriverContract, ObjectVisibility } from 'flydrive/types'
import type { CustomDiskConfig } from '@arkstack/filesystem'
export class CloudinaryFileDriver implements DriverContract {
constructor(private config?: CustomDiskConfig) {}
async exists(key: string) {}
async get(key: string) {}
async getStream(key: string) {}
async getBytes(key: string) {}
async getMetaData(key: string) {}
async getVisibility(): Promise<ObjectVisibility> {}
async getUrl(key: string) {}
async getSignedUrl(key: string) {}
async getSignedUploadUrl(key: string) {}
async setVisibility() {}
async put() {}
async putStream() {}
async copy() {}
async move() {}
async delete() {}
async deleteAll() {}
async listAll() {}
async bucket() {}
}
sc/配置/文件系统.ts
import { CloudinaryFileDriver } from '../CloudinaryFileDriver'
export default () => {
return {
default: 'images',
disks: {
images: {
//...Other Disks Here
driver: 'cloudinary',
},
},
links: {},
custom_drivers: {
cloudinary: CloudinaryFileDriver,
},
}
}
为了改进型号安全和自动完成,您可以增加 CustomDiskDriverRegistry
d.t.节
declare module '@arkstack/filesystem' {
interface CustomDiskDriverRegistry {
cloudinary: { cloud_name: string; api_key: string; api_secret: string }
}
}