t-comm
Version:
专业、稳定、纯粹的工具库
96 lines (95 loc) • 2.83 kB
TypeScript
import type { ICosMeta } from './types';
/**
* COS上传
* @param {object} config 配置信息
* @param {Array<object>} config.files 文件列表
* @param {string} config.files.key 文件key
* @param {string} config.files.path 文件路径
* @param {string} [config.files.ContentType] 文件 MIME 类型(如 image/svg+xml),不传则由 COS 根据扩展名推断
* @param {string} config.secretId COS secretId
* @param {string} config.secretKey COS secretKey
* @param {string} config.bucket COS bucket
* @param {string} config.region COS region
* @returns {Promise<object>} 请求Promise
*
* @example
*
* uploadCOSFile({
* files: [{
* key: 'key1',
* path: 'path1',
* }, {
* key: 'key2',
* path: 'path2',
* }],
* secretId: 'xxx',
* secretKey: 'xxx',
* bucket: 'xxx',
* region: 'xxx',
* })
*/
export declare function uploadCOSFile({ files, secretId, secretKey, bucket, region, }: {
files: Array<{
key: string;
path: string;
ContentType?: string;
}>;
secretId: string;
secretKey: string;
bucket: string;
region: string;
}): Promise<any>;
/**
* 获取 COS 存储桶中的文件列表
* @param {object} config 配置信息
* @param {string} config.secretId COS secretId
* @param {string} config.secretKey COS secretKey
* @param {string} config.bucket COS bucket
* @param {string} config.region COS region
* @param {string} config.prefix 文件前缀过滤
* @returns {Promise<Array<ICosMeta>>} 文件元信息列表
* @example
* ```ts
* const list = await getCOSBucketList({
* secretId: 'xxx',
* secretKey: 'xxx',
* bucket: 'my-bucket-1250000000',
* region: 'ap-guangzhou',
* prefix: 'static/',
* });
* ```
*/
export declare function getCOSBucketList({ secretId, secretKey, bucket, region, prefix, }: {
secretId: string;
secretKey: string;
bucket: string;
region: string;
prefix: string;
}): Promise<Array<ICosMeta>>;
/**
* 批量删除 COS 存储桶中的多个对象
* @param {object} config 配置信息
* @param {string} config.secretId COS secretId
* @param {string} config.secretKey COS secretKey
* @param {Array<string>} config.keys 要删除的对象 key 列表
* @param {string} config.bucket COS bucket
* @param {string} config.region COS region
* @returns {Promise<any>} 删除结果
* @example
* ```ts
* await deleteCOSMultipleObject({
* secretId: 'xxx',
* secretKey: 'xxx',
* keys: ['static/old-file1.js', 'static/old-file2.js'],
* bucket: 'my-bucket-1250000000',
* region: 'ap-guangzhou',
* });
* ```
*/
export declare function deleteCOSMultipleObject({ secretId, secretKey, keys, bucket, region, }: {
secretId: string;
secretKey: string;
bucket: string;
region: string;
keys: Array<string>;
}): Promise<unknown>;