@nocobase/plugin-file-manager
Version:
Provides files storage services with files collection template and attachment field.
62 lines (61 loc) • 2.18 kB
TypeScript
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
/// <reference types="node" />
import { Model, Transactionable } from '@nocobase/database';
import { Plugin } from '@nocobase/server';
import { Registry } from '@nocobase/utils';
import { Readable } from 'stream';
import { AttachmentModel, GetFileStreamOptions, StorageClassType, StorageModel } from './storages';
export type * from './storages';
export type FileRecordOptions = {
collectionName: string;
filePath: string;
storageName?: string;
subPath?: string;
values?: any;
} & Transactionable;
export type UploadFileOptions = {
filePath: string;
storageName?: string;
subPath?: string;
documentRoot?: string;
};
export declare class PluginFileManagerServer extends Plugin {
storageTypes: Registry<StorageClassType>;
storagesCache: Map<string | number, StorageModel>;
static staticImport(): Promise<void>;
afterDestroy: (record: Model, options: any) => Promise<void>;
registerStorageType(type: string, Type: StorageClassType): void;
createFileRecord(options: FileRecordOptions): Promise<any>;
parseStorage(instance: any): any;
uploadFile(options: UploadFileOptions): Promise<{
title: string;
filename: string;
extname: string;
path: string;
size: any;
mimetype: any;
meta: {};
storageId: number;
}>;
loadStorages(options?: {
transaction: any;
}): Promise<void>;
install(): Promise<void>;
handleSyncMessage(message: any): Promise<void>;
beforeLoad(): Promise<void>;
load(): Promise<void>;
getFileURL(file: AttachmentModel, preview?: boolean): Promise<any>;
isPublicAccessStorage(storageName: any): Promise<boolean>;
getFileStream(file: AttachmentModel, options?: GetFileStreamOptions): Promise<{
stream: Readable;
contentType?: string;
}>;
}
export default PluginFileManagerServer;