From 36408a051653a9703a762c2b7dd2da17d60dea0a Mon Sep 17 00:00:00 2001 From: otakustay Date: Tue, 20 Sep 2022 11:24:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(bos):=20=E6=94=AF=E6=8C=81getObjectMeta=20?= =?UTF-8?q?(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bos/bucket.ts | 4 ++++ src/bos/index.ts | 4 ++++ src/bos/object.ts | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/src/bos/bucket.ts b/src/bos/bucket.ts index c129f60..f1a347d 100644 --- a/src/bos/bucket.ts +++ b/src/bos/bucket.ts @@ -69,6 +69,10 @@ export class BosBucketClient { return this.withObject(key).get(); } + async getObjectMeta(key: string) { + return this.withObject(key).getMeta(); + } + async getObjectAsBlob(key: string) { return this.withObject(key).getAsBlob(); } diff --git a/src/bos/index.ts b/src/bos/index.ts index 108796f..bb3ecf2 100644 --- a/src/bos/index.ts +++ b/src/bos/index.ts @@ -41,6 +41,10 @@ export class BosClient { return this.withObject(bucketName, key).get(); } + async getObjectMeta(bucketName: string, key: string) { + return this.withObject(bucketName, key).getMeta(); + } + async getObjectAsBlob(bucketName: string, key: string) { return this.withObject(bucketName, key).getAsBlob(); } diff --git a/src/bos/object.ts b/src/bos/object.ts index 9131352..273bfb1 100644 --- a/src/bos/object.ts +++ b/src/bos/object.ts @@ -22,6 +22,11 @@ export class BosObjectClient { return response; } + async getMeta() { + const response = await this.http.noContent('HEAD', `/${this.objectKey}`); + return response; + } + async getAsBlob() { const response = await this.http.blob('GET', `/${this.objectKey}`); return response;