UNPKG

oss-client

Version:

Aliyun OSS(Object Storage Service) Node.js Client

164 lines (163 loc) 8.04 kB
import type { Readable, Writable } from 'node:stream'; import type { ListObjectsQuery, RequestOptions, ListObjectResult, PutObjectOptions, PutObjectResult, UserMeta, DeleteObjectOptions, DeleteObjectResult, GetObjectOptions, GetObjectResult, SignatureUrlOptions, HeadObjectOptions, HeadObjectResult, IObjectSimple, GetStreamOptions, GetStreamResult, CopyObjectOptions, CopyAndPutMetaResult } from 'oss-interface'; import { type OSSBaseClientInitOptions, OSSBaseClient } from './OSSBaseClient.js'; import type { ACLType, AppendObjectOptions, AppendObjectResult, DeleteMultipleObject, DeleteMultipleObjectOptions, DeleteMultipleObjectResponse, DeleteObjectTaggingOptions, DeleteObjectTaggingResult, GetACLOptions, GetACLResult, GetSymlinkOptions, GetSymlinkResult, GutObjectTaggingOptions, GutObjectTaggingResult, ListV2ObjectResult, ListV2ObjectsQuery, PutACLOptions, PutACLResult, PutObjectTaggingOptions, PutObjectTaggingResult, PutSymlinkOptions, PutSymlinkResult } from './type/index.js'; export interface OSSObjectClientInitOptions extends OSSBaseClientInitOptions { bucket?: string; /** * Enable cname * @see https://help.aliyun.com/zh/oss/user-guide/map-custom-domain-names-5 */ cname?: boolean; } export declare class OSSObject extends OSSBaseClient implements IObjectSimple { #private; constructor(options: OSSObjectClientInitOptions); /** public methods */ /** * AppendObject * @see https://help.aliyun.com/zh/oss/developer-reference/appendobject */ append(name: string, file: string | Buffer | Readable, options?: AppendObjectOptions): Promise<AppendObjectResult>; /** * put an object from String(file path)/Buffer/Readable * @param {String} name the object key * @param {Mixed} file String(file path)/Buffer/Readable * @param {Object} options options * {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64 * {String} options.callback.url the OSS sends a callback request to this URL * {String} options.callback.host The host header value for initiating callback requests * {String} options.callback.body The value of the request body when a callback is initiated * {String} options.callback.contentType The Content-Type of the callback requests initiated * {Object} options.callback.customValue Custom parameters are a map of key-values, e.g: * customValue = { * key1: 'value1', * key2: 'value2' * } * @returns {Object} result */ put(name: string, file: string | Buffer | Readable, options?: PutObjectOptions): Promise<PutObjectResult>; /** * put an object from ReadableStream. */ putStream(name: string, stream: Readable, options?: PutObjectOptions): Promise<PutObjectResult>; putMeta(name: string, meta: UserMeta, options?: Omit<CopyObjectOptions, 'meta'>): Promise<CopyAndPutMetaResult>; /** * GetBucket (ListObjects) * @see https://help.aliyun.com/zh/oss/developer-reference/listobjects */ list(query?: ListObjectsQuery, options?: RequestOptions): Promise<ListObjectResult>; /** * ListObjectsV2(GetBucketV2) * @see https://help.aliyun.com/zh/oss/developer-reference/listobjectsv2 */ listV2(query?: ListV2ObjectsQuery, options?: RequestOptions): Promise<ListV2ObjectResult>; /** * GetObject * @see https://help.aliyun.com/zh/oss/developer-reference/getobject */ get(name: string, options?: GetObjectOptions): Promise<GetObjectResult>; get(name: string, file: string | Writable, options?: GetObjectOptions): Promise<GetObjectResult>; getStream(name: string, options?: GetStreamOptions): Promise<GetStreamResult>; /** * PutObjectACL * @see https://help.aliyun.com/zh/oss/developer-reference/putobjectacl */ putACL(name: string, acl: ACLType, options?: PutACLOptions): Promise<PutACLResult>; /** * GetObjectACL * @see https://help.aliyun.com/zh/oss/developer-reference/getobjectacl */ getACL(name: string, options?: GetACLOptions): Promise<GetACLResult>; /** * DeleteObject * @see https://help.aliyun.com/zh/oss/developer-reference/deleteobject */ delete(name: string, options?: DeleteObjectOptions): Promise<DeleteObjectResult>; /** * DeleteMultipleObjects * @see https://help.aliyun.com/zh/oss/developer-reference/deletemultipleobjects */ deleteMulti(namesOrObjects: string[] | DeleteMultipleObject[], options?: DeleteMultipleObjectOptions): Promise<DeleteMultipleObjectResponse>; /** * HeadObject * @see https://help.aliyun.com/zh/oss/developer-reference/headobject */ head(name: string, options?: HeadObjectOptions): Promise<HeadObjectResult>; /** * GetObjectMeta * @see https://help.aliyun.com/zh/oss/developer-reference/getobjectmeta */ getObjectMeta(name: string, options?: HeadObjectOptions): Promise<{ status: number; res: import("urllib").RawResponseWithMeta; }>; /** * PutSymlink * @see https://help.aliyun.com/zh/oss/developer-reference/putsymlink */ putSymlink(name: string, targetName: string, options: PutSymlinkOptions): Promise<PutSymlinkResult>; /** * GetSymlink * @see https://help.aliyun.com/zh/oss/developer-reference/getsymlink */ getSymlink(name: string, options?: GetSymlinkOptions): Promise<GetSymlinkResult>; /** * PutObjectTagging * @see https://help.aliyun.com/zh/oss/developer-reference/putobjecttagging */ putObjectTagging(name: string, tag: Record<string, string>, options?: PutObjectTaggingOptions): Promise<PutObjectTaggingResult>; /** * GetObjectTagging * @see https://help.aliyun.com/zh/oss/developer-reference/getobjecttagging */ getObjectTagging(name: string, options?: GutObjectTaggingOptions): Promise<GutObjectTaggingResult>; /** * DeleteObjectTagging * @see https://help.aliyun.com/zh/oss/developer-reference/deleteobjecttagging */ deleteObjectTagging(name: string, options?: DeleteObjectTaggingOptions): Promise<DeleteObjectTaggingResult>; /** * signatureUrl URL签名 * @see https://help.aliyun.com/zh/oss/developer-reference/signed-urls */ signatureUrl(name: string, options?: SignatureUrlOptions): string; asyncSignatureUrl(name: string, options?: SignatureUrlOptions): Promise<string>; /** * Get Object url by name * @param {string} name - object name * @param {string} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint and bucket`. * @returns {string} object url include bucket */ generateObjectUrl(name: string, baseUrl?: string): string; /** * @alias generateObjectUrl */ getObjectUrl(name: string, baseUrl?: string): string; /** * @param {object | string} policy specifies the validity of the fields in the request. * @returns {object} params.OSSAccessKeyId * params.Signature * params.policy JSON text encoded with UTF-8 and Base64. */ calculatePostSignature(policy: object | string): { OSSAccessKeyId: string; Signature: string; policy: string; }; /** * Copy an object from sourceName to name. */ copy(name: string, sourceName: string, options?: CopyObjectOptions): Promise<CopyAndPutMetaResult>; copy(name: string, sourceName: string, sourceBucket: string, options?: CopyObjectOptions): Promise<CopyAndPutMetaResult>; /** * 另存为 * @see https://help.aliyun.com/zh/oss/user-guide/sys-or-saveas */ processObjectSave(sourceObject: string, targetObject: string, process: string, targetBucket?: string): Promise<{ res: import("urllib").RawResponseWithMeta; status: number; }>; /** protected methods */ protected getRequestEndpoint(): string; }