/** * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * @file src/bcs_client.ts * @author leeight */ import * as H from './headers'; import BceBaseClient from './bce_base_client'; import type { BceConfig, BceResponse } from './types/common'; /** BCS 配置选项 */ interface BcsClientOptions { config?: Partial; headers?: Record; } /** 访问控制列表 */ interface AccessControlList { accessControlList: Array<{ grantee: Array<{ id: string; }>; permission: Array; }>; } /** 对象元数据 */ interface ObjectMetadata { [H.CONTENT_TYPE]?: string; [H.CONTENT_LENGTH]?: number; [H.CONTENT_MD5]?: string; [key: string]: any; } /** 列出对象的选项 */ interface ListObjectsOptions extends BcsClientOptions { start?: string; limit?: number; } /** 存储桶信息 */ interface Bucket { name: string; creationDate: string; } /** 对象信息 */ interface BcsObject { key: string; lastModified: string; eTag: string; size: number; storageClass: string; owner: { id: string; displayName: string; }; } /** * BCS service API client * * @see http://developer.baidu.com/wiki/index.php?title=docs/cplat/bcs/api */ export default class BcsClient extends BceBaseClient { /** * 构造函数 * @param config BCS 客户端配置 */ constructor(config: BceConfig); /** * 列出所有存储桶 * @param options 选项 * @returns Promise 解析为存储桶列表 */ listBuckets(options?: BcsClientOptions): Promise>; /** * 创建存储桶 * @param bucketName 存储桶名称 * @param options 选项 * @returns Promise 解析为创建结果 */ createBucket(bucketName: string, options?: BcsClientOptions): Promise>; /** * 设置存储桶访问控制列表 * @param bucketName 存储桶名称 * @param acl 访问控制列表 * @param options 选项 * @returns Promise 解析为设置结果 */ setBucketAcl(bucketName: string, acl: AccessControlList['accessControlList'], options?: BcsClientOptions): Promise>; /** * 设置存储桶预定义访问控制权限 * @param bucketName 存储桶名称 * @param cannedAcl 预定义权限 * @param options 选项 * @returns Promise 解析为设置结果 */ setBucketCannedAcl(bucketName: string, cannedAcl: string, options?: BcsClientOptions): Promise>; /** * 获取存储桶访问控制列表 * @param bucketName 存储桶名称 * @param options 选项 * @returns Promise 解析为访问控制列表 */ getBucketAcl(bucketName: string, options?: BcsClientOptions): Promise>; /** * 删除存储桶 * @param bucketName 存储桶名称 * @param options 选项 * @returns Promise 解析为删除结果 */ deleteBucket(bucketName: string, options?: BcsClientOptions): Promise>; /** * 删除对象 * @param bucketName 存储桶名称 * @param key 对象键 * @param options 选项 * @returns Promise 解析为删除结果 */ deleteObject(bucketName: string, key: string, options?: BcsClientOptions): Promise>; /** * 列出对象 * @param bucketName 存储桶名称 * @param options 选项 * @returns Promise 解析为对象列表 */ listObjects(bucketName: string, options?: ListObjectsOptions): Promise>; /** * 获取对象元数据 * @param bucketName 存储桶名称 * @param key 对象键 * @param options 选项 * @returns Promise 解析为对象元数据 */ getObjectMetadata(bucketName: string, key: string, options?: BcsClientOptions): Promise>; /** * 上传对象 * @param bucketName 存储桶名称 * @param key 对象键 * @param data 数据 * @param options 选项 * @returns Promise 解析为上传结果 */ putObject(bucketName: string, key: string, data: any, options?: BcsClientOptions): Promise>; /** * 从 Blob 上传对象(浏览器环境) * @param bucketName 存储桶名称 * @param key 对象键 * @param blob Blob 对象 * @param options 选项 * @returns Promise 解析为上传结果 */ putObjectFromBlob(bucketName: string, key: string, blob: Blob, options?: BcsClientOptions): Promise>; /** * 从字符串上传对象 * @param bucketName 存储桶名称 * @param key 对象键 * @param data 字符串数据 * @param options 选项 * @returns Promise 解析为上传结果 */ putObjectFromString(bucketName: string, key: string, data: string, options?: BcsClientOptions): Promise>; /** * 从文件上传对象 * @param bucketName 存储桶名称 * @param key 对象键 * @param filename 文件路径 * @param options 选项 * @returns Promise 解析为上传结果 */ putObjectFromFile(bucketName: string, key: string, filename: string, options?: BcsClientOptions): Promise>; /** * 检查选项参数 * @param options 选项 * @returns 检查后的选项 */ private _checkOptions; } export {}; //# sourceMappingURL=bcs_client.d.ts.map