@maiyunnet/kebab 9.15.2 → 9.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/doc/kebab-rag.md CHANGED
@@ -1361,7 +1361,7 @@ index/variables/VER.md
1361
1361
 
1362
1362
  # Variable: VER
1363
1363
 
1364
- > `const` **VER**: `"9.15.2"` = `'9.15.2'`
1364
+ > `const` **VER**: `"9.15.3"` = `'9.15.3'`
1365
1365
 
1366
1366
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1367
1367
 
@@ -12488,7 +12488,7 @@ Defined in: [lib/s3.ts:88](https://github.com/maiyunnet/kebab/blob/master/lib/s3
12488
12488
 
12489
12489
  > **deleteObject**(`key`, `bucket?`): `Promise`\<`boolean`\>
12490
12490
 
12491
- Defined in: [lib/s3.ts:255](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L255)
12491
+ Defined in: [lib/s3.ts:279](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L279)
12492
12492
 
12493
12493
  删除对象
12494
12494
 
@@ -12516,7 +12516,7 @@ bucket 名
12516
12516
 
12517
12517
  > **deleteObjects**(`keys`, `bucket?`): `Promise`\<`boolean`\>
12518
12518
 
12519
- Defined in: [lib/s3.ts:275](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L275)
12519
+ Defined in: [lib/s3.ts:299](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L299)
12520
12520
 
12521
12521
  批量删除对象
12522
12522
 
@@ -12544,7 +12544,7 @@ bucket 名
12544
12544
 
12545
12545
  > **destroy**(): `void`
12546
12546
 
12547
- Defined in: [lib/s3.ts:317](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L317)
12547
+ Defined in: [lib/s3.ts:341](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L341)
12548
12548
 
12549
12549
  销毁连接,释放资源
12550
12550
  一般会自动垃圾回收,但高频接口也可主动调用
@@ -12583,11 +12583,41 @@ bucket 名
12583
12583
 
12584
12584
  ***
12585
12585
 
12586
+ ### getObjectBuffer()
12587
+
12588
+ > **getObjectBuffer**(`key`, `bucket?`): `Promise`\<`false` \| `Buffer`\<`ArrayBufferLike`\>\>
12589
+
12590
+ Defined in: [lib/s3.ts:256](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L256)
12591
+
12592
+ 获取对象 Buffer
12593
+
12594
+ #### Parameters
12595
+
12596
+ ##### key
12597
+
12598
+ `string`
12599
+
12600
+ 对象路径
12601
+
12602
+ ##### bucket?
12603
+
12604
+ `string`
12605
+
12606
+ bucket 名
12607
+
12608
+ #### Returns
12609
+
12610
+ `Promise`\<`false` \| `Buffer`\<`ArrayBufferLike`\>\>
12611
+
12612
+ 对象内容,获取失败或对象无内容时返回 false
12613
+
12614
+ ***
12615
+
12586
12616
  ### headObject()
12587
12617
 
12588
12618
  > **headObject**(`key`, `bucket?`): `Promise`\<`false` \| `HeadObjectCommandOutput`\>
12589
12619
 
12590
- Defined in: [lib/s3.ts:297](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L297)
12620
+ Defined in: [lib/s3.ts:321](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L321)
12591
12621
 
12592
12622
  检测对象是否存在
12593
12623
 
@@ -12787,7 +12817,7 @@ lib/s3/functions/get.md
12787
12817
 
12788
12818
  > **get**(`ctr`, `opt`): [`S3`](../classes/S3.md)
12789
12819
 
12790
- Defined in: [lib/s3.ts:327](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L327)
12820
+ Defined in: [lib/s3.ts:351](https://github.com/maiyunnet/kebab/blob/master/lib/s3.ts#L351)
12791
12821
 
12792
12822
  创建一个对象存储对象
12793
12823
 
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.15.2";
8
+ export declare const VER = "9.15.3";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.15.2';
9
+ export const VER = '9.15.3';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/s3.d.ts CHANGED
@@ -101,6 +101,13 @@ export declare class S3 {
101
101
  * @param bucket bucket 名
102
102
  */
103
103
  getObject(key: string, bucket?: string): Promise<false | (stream.Readable & import("@smithy/types").SdkStreamMixin) | (Blob & import("@smithy/types").SdkStreamMixin) | (ReadableStream<any> & import("@smithy/types").SdkStreamMixin) | undefined>;
104
+ /**
105
+ * --- 获取对象 Buffer ---
106
+ * @param key 对象路径
107
+ * @param bucket bucket 名
108
+ * @returns 对象内容,获取失败或对象无内容时返回 false
109
+ */
110
+ getObjectBuffer(key: string, bucket?: string): Promise<Buffer | false>;
104
111
  /**
105
112
  * --- 删除对象 ---
106
113
  * @param key 对象路径
package/lib/s3.js CHANGED
@@ -163,6 +163,29 @@ export class S3 {
163
163
  return false;
164
164
  }
165
165
  }
166
+ /**
167
+ * --- 获取对象 Buffer ---
168
+ * @param key 对象路径
169
+ * @param bucket bucket 名
170
+ * @returns 对象内容,获取失败或对象无内容时返回 false
171
+ */
172
+ async getObjectBuffer(key, bucket) {
173
+ try {
174
+ const go = new s3.GetObjectCommand({
175
+ 'Bucket': bucket ?? this._bucket,
176
+ 'Key': key
177
+ });
178
+ const r = await this._link.send(go);
179
+ if (!r.Body) {
180
+ return false;
181
+ }
182
+ return Buffer.from(await r.Body.transformToByteArray());
183
+ }
184
+ catch (e) {
185
+ lCore.log(this._ctr, '[LIB][S3][getObjectBuffer] ' + lText.stringifyJson(e.message ?? '').slice(1, -1).replace(/"/g, '""'), '-error');
186
+ return false;
187
+ }
188
+ }
166
189
  /**
167
190
  * --- 删除对象 ---
168
191
  * @param key 对象路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.15.2",
3
+ "version": "9.15.3",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [