@kevisual/oss 0.0.18 → 0.0.19
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/dist/index.d.ts +2 -0
- package/dist/index.js +10 -2
- package/dist/services.d.ts +3 -0
- package/dist/services.js +10 -2
- package/package.json +1 -1
- package/src/s3/core.ts +11 -4
- package/src/s3/type.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ type ListFileObject = {
|
|
|
28
28
|
size: number;
|
|
29
29
|
lastModified: Date;
|
|
30
30
|
etag: string;
|
|
31
|
+
metaData?: ItemBucketMetadata;
|
|
31
32
|
};
|
|
32
33
|
type ListDirectoryObject = {
|
|
33
34
|
prefix: string;
|
|
@@ -216,6 +217,7 @@ declare class OssBase implements OssBaseOperation {
|
|
|
216
217
|
recursive?: boolean;
|
|
217
218
|
startAfter?: string;
|
|
218
219
|
maxKeys?: number;
|
|
220
|
+
getMeta?: boolean;
|
|
219
221
|
}): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]>;
|
|
220
222
|
/**
|
|
221
223
|
* 获取对象信息
|
package/dist/index.js
CHANGED
|
@@ -36552,6 +36552,7 @@ class OssBase {
|
|
|
36552
36552
|
const prefix = `${this.prefix}${objectName}`;
|
|
36553
36553
|
const results = [];
|
|
36554
36554
|
let continuationToken;
|
|
36555
|
+
const getMeta = opts?.getMeta ?? false;
|
|
36555
36556
|
do {
|
|
36556
36557
|
const command = new import_client_s3.ListObjectsV2Command({
|
|
36557
36558
|
Bucket: this.bucketName,
|
|
@@ -36564,12 +36565,19 @@ class OssBase {
|
|
|
36564
36565
|
const response = await this.client.send(command);
|
|
36565
36566
|
if (response.Contents) {
|
|
36566
36567
|
for (const item of response.Contents) {
|
|
36567
|
-
|
|
36568
|
+
const result = {
|
|
36568
36569
|
name: item.Key || "",
|
|
36569
36570
|
size: item.Size || 0,
|
|
36570
36571
|
lastModified: item.LastModified || new Date,
|
|
36571
36572
|
etag: item.ETag?.replace(/"/g, "") || ""
|
|
36572
|
-
}
|
|
36573
|
+
};
|
|
36574
|
+
if (getMeta) {
|
|
36575
|
+
const stat = await this.statObject(item.Key || "", false);
|
|
36576
|
+
if (stat?.metaData) {
|
|
36577
|
+
result.metaData = stat.metaData;
|
|
36578
|
+
}
|
|
36579
|
+
}
|
|
36580
|
+
results.push(result);
|
|
36573
36581
|
}
|
|
36574
36582
|
}
|
|
36575
36583
|
if (response.CommonPrefixes && !opts?.recursive) {
|
package/dist/services.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ type ListFileObject = {
|
|
|
28
28
|
size: number;
|
|
29
29
|
lastModified: Date;
|
|
30
30
|
etag: string;
|
|
31
|
+
metaData?: ItemBucketMetadata;
|
|
31
32
|
};
|
|
32
33
|
type ListDirectoryObject = {
|
|
33
34
|
prefix: string;
|
|
@@ -216,6 +217,7 @@ declare class OssBase implements OssBaseOperation {
|
|
|
216
217
|
recursive?: boolean;
|
|
217
218
|
startAfter?: string;
|
|
218
219
|
maxKeys?: number;
|
|
220
|
+
getMeta?: boolean;
|
|
219
221
|
}): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]>;
|
|
220
222
|
/**
|
|
221
223
|
* 获取对象信息
|
|
@@ -291,6 +293,7 @@ declare class ConfigOssService extends OssBase implements OssService {
|
|
|
291
293
|
size: number;
|
|
292
294
|
lastModified: Date;
|
|
293
295
|
etag: string;
|
|
296
|
+
metaData?: ItemBucketMetadata;
|
|
294
297
|
}[];
|
|
295
298
|
keys: string[];
|
|
296
299
|
keyEtagMap: Map<string, string>;
|
package/dist/services.js
CHANGED
|
@@ -36556,6 +36556,7 @@ class OssBase {
|
|
|
36556
36556
|
const prefix = `${this.prefix}${objectName}`;
|
|
36557
36557
|
const results = [];
|
|
36558
36558
|
let continuationToken;
|
|
36559
|
+
const getMeta = opts?.getMeta ?? false;
|
|
36559
36560
|
do {
|
|
36560
36561
|
const command = new import_client_s3.ListObjectsV2Command({
|
|
36561
36562
|
Bucket: this.bucketName,
|
|
@@ -36568,12 +36569,19 @@ class OssBase {
|
|
|
36568
36569
|
const response = await this.client.send(command);
|
|
36569
36570
|
if (response.Contents) {
|
|
36570
36571
|
for (const item of response.Contents) {
|
|
36571
|
-
|
|
36572
|
+
const result = {
|
|
36572
36573
|
name: item.Key || "",
|
|
36573
36574
|
size: item.Size || 0,
|
|
36574
36575
|
lastModified: item.LastModified || new Date,
|
|
36575
36576
|
etag: item.ETag?.replace(/"/g, "") || ""
|
|
36576
|
-
}
|
|
36577
|
+
};
|
|
36578
|
+
if (getMeta) {
|
|
36579
|
+
const stat = await this.statObject(item.Key || "", false);
|
|
36580
|
+
if (stat?.metaData) {
|
|
36581
|
+
result.metaData = stat.metaData;
|
|
36582
|
+
}
|
|
36583
|
+
}
|
|
36584
|
+
results.push(result);
|
|
36577
36585
|
}
|
|
36578
36586
|
}
|
|
36579
36587
|
if (response.CommonPrefixes && !opts?.recursive) {
|
package/package.json
CHANGED
package/src/s3/core.ts
CHANGED
|
@@ -258,12 +258,12 @@ export class OssBase implements OssBaseOperation {
|
|
|
258
258
|
*/
|
|
259
259
|
async listObjects<IS_FILE = false>(
|
|
260
260
|
objectName: string,
|
|
261
|
-
opts?: { recursive?: boolean; startAfter?: string; maxKeys?: number },
|
|
261
|
+
opts?: { recursive?: boolean; startAfter?: string; maxKeys?: number, getMeta?: boolean },
|
|
262
262
|
): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]> {
|
|
263
263
|
const prefix = `${this.prefix}${objectName}`;
|
|
264
264
|
const results: ListObjectResult[] = [];
|
|
265
265
|
let continuationToken: string | undefined;
|
|
266
|
-
|
|
266
|
+
const getMeta = opts?.getMeta ?? false;
|
|
267
267
|
do {
|
|
268
268
|
const command = new ListObjectsV2Command({
|
|
269
269
|
Bucket: this.bucketName,
|
|
@@ -279,12 +279,19 @@ export class OssBase implements OssBaseOperation {
|
|
|
279
279
|
// 处理文件对象
|
|
280
280
|
if (response.Contents) {
|
|
281
281
|
for (const item of response.Contents) {
|
|
282
|
-
|
|
282
|
+
const result: ListFileObject = {
|
|
283
283
|
name: item.Key || '',
|
|
284
284
|
size: item.Size || 0,
|
|
285
285
|
lastModified: item.LastModified || new Date(),
|
|
286
286
|
etag: item.ETag?.replace(/"/g, '') || '',
|
|
287
|
-
}
|
|
287
|
+
}
|
|
288
|
+
if (getMeta) {
|
|
289
|
+
const stat = await this.statObject(item.Key || '', false);
|
|
290
|
+
if (stat?.metaData) {
|
|
291
|
+
result.metaData = stat.metaData;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
results.push(result);
|
|
288
295
|
}
|
|
289
296
|
}
|
|
290
297
|
|