import OSS from 'ali-oss'; import { IOssConfig } from '../interface'; export declare class OssClient { cfg: IOssConfig; client: OSS; constructor(config: IOssConfig); getHostUrl(): string; getRootUrl(): string; private formatOssPath; /** * 设置数据存储的生命周期 默认root目录 * @param days * @param childPaths */ setLifeCycle(days: number, childPaths?: string[]): Promise; /** * 删除生命周期规则 * bucket维度全部的规则 */ delLifeCycle(): Promise; /** * 查询生命周期 */ getLifeCycle(): Promise; /** * 删除一个oss文件 * 支持删除指定版本 * @param ossFile * @param opts */ deleteFile(ossFile: any, opts?: { versionId?: string; }): Promise; deleteFolder(ossPath: any): Promise; getFolders(ossPath: any): Promise; getFiles(ossPath: any): Promise<{ name: string; url: string; lastModified: string; etag: string; type: string; size: number; storageClass: string; owner: { id: string; displayName: string; }; }[]>; getFileStr(ossFile: string): Promise; /** * 读取JSON文件, 不存在时返回 {} * @param ossFile */ getJSON(ossFile: any): Promise; putJSON(obj: any, ossFile: any): Promise; putTxt(str: string, ossFile: string): Promise; /** * key-json对象存储,有新值则更新 * 返回存储值 * @param key * @param obj * @param merge 是否合并,默认替换 */ store(key: string, obj?: object, merge?: boolean): Promise; /** * 上传单个文件, 未指定oss文件时上传为临时文件 */ put(localFile: string, ossFile?: string): Promise; /** * 上传文件从url获取文件转存oss * @param url * @param ossFile */ putUrl(url: string, ossFile?: string): Promise; get(ossFile: any, localFile: any): Promise; /** * 检查oss文件、文件夹是否存在 * @param ossFile */ exist(ossFile: any): Promise; postDirZip(localPath: any, ossFile: any): Promise; /** * 压缩本地文件夹,上传到oss * @param localPath * @param ossFile */ postDirTarGz(localPath: any, ossFile: any): Promise; /** * 上传整个文件夹 * @param localPath * @param ossFile */ postDir(localPath: any, ossFile: any): Promise; /** * 下载oss上的一个文件夹 * @param ossDir * @param destDir * @param dealer */ getFilesByPath(ossDir: any, destDir: any, dealer?: any): Promise; /** * 获取对象Meta信息,实际是headers * @param ossFile */ getObjectMeta(ossFile: any): Promise<{ 'content-length': string; 'last-modified': string; etag: string; 'x-oss-hash-crc64ecma': string; 'x-oss-version-id': string; }>; /** * 删除最近上传的版本 * 默认删除最近一分钟内的所有新增版本 * @param ossFile * @param afterTime 某个时间点之后(oss记录时间) * @param limit 删除上限,默认不限制 */ deleteObjectRecentVersions(ossFile: string, afterTime: Date, limit?: number): Promise; }