UNPKG

@cool-midway/file

Version:

cool-admin一个很酷的后台权限管理系统,开源免费,模块化、插件化、极速开发CRUD,方便快速构建迭代后台管理系统

72 lines (71 loc) 1.69 kB
import { Mode, CoolFileConfig } from './interface'; import { ILogger, IMidwayApplication } from '@midwayjs/core'; import * as OSS from 'ali-oss'; import * as COS from 'cos-nodejs-sdk-v5'; import * as QINIU from 'qiniu'; import { S3Client } from '@aws-sdk/client-s3'; /** * 文件上传 */ export declare class CoolFile { config: CoolFileConfig; coreLogger: ILogger; client: OSS & COS & QINIU.auth.digest.Mac & S3Client; app: IMidwayApplication; init(config: CoolFileConfig): Promise<void>; /** * 上传模式 * @returns 上传模式 */ getMode(): Promise<Mode>; /** * 获得原始操作对象 * @returns */ getMetaFileObj(): OSS & COS & QINIU.auth.digest.Mac & S3Client; /** * 下载并上传 * @param url * @param fileName 文件名 */ downAndUpload(url: string, fileName?: string): Promise<any>; /** * 指定Key(路径)上传 * @param filePath 文件路径 * @param key 路径一致会覆盖源文件 */ uploadWithKey(filePath: any, key: any): Promise<any>; /** * 上传文件 * @param ctx * @param key 文件路径 */ upload(ctx: any): Promise<unknown>; /** * aws 文件上传 * @param ctx */ private aws; /** * 七牛上传 * @param ctx * @returns */ private qiniu; /** * OSS 文件上传 * @param ctx */ private oss; /** * COS 文件上传 * @param ctx */ private cos; /** * 本地上传 * @param ctx * @returns */ private local; }