@kevisual/oss 0.0.17 → 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 +15 -2
- package/dist/index.js +67 -20
- package/dist/services.d.ts +35 -130
- package/dist/services.js +60 -77
- package/package.json +2 -3
- package/src/index.ts +3 -1
- package/src/s3/core.ts +72 -23
- package/src/s3/type.ts +8 -0
- package/src/services/index.ts +1 -1
- package/src/util/download.ts +69 -69
- package/src/core/copy-object.ts +0 -26
- package/src/core/core.ts +0 -244
- package/src/core/type.ts +0 -87
package/dist/index.d.ts
CHANGED
|
@@ -15,12 +15,20 @@ type StatObjectResult = {
|
|
|
15
15
|
lastModified: Date;
|
|
16
16
|
metaData: ItemBucketMetadata;
|
|
17
17
|
versionId?: string | null;
|
|
18
|
+
standardHeaders: {
|
|
19
|
+
contentType?: string;
|
|
20
|
+
cacheControl?: string;
|
|
21
|
+
contentDisposition?: string;
|
|
22
|
+
contentEncoding?: string;
|
|
23
|
+
contentLanguage?: string;
|
|
24
|
+
};
|
|
18
25
|
};
|
|
19
26
|
type ListFileObject = {
|
|
20
27
|
name: string;
|
|
21
28
|
size: number;
|
|
22
29
|
lastModified: Date;
|
|
23
30
|
etag: string;
|
|
31
|
+
metaData?: ItemBucketMetadata;
|
|
24
32
|
};
|
|
25
33
|
type ListDirectoryObject = {
|
|
26
34
|
prefix: string;
|
|
@@ -129,6 +137,9 @@ interface OssBaseOperation {
|
|
|
129
137
|
*/
|
|
130
138
|
replaceObject?(objectName: string, meta: ItemBucketMetadata): Promise<any>;
|
|
131
139
|
}
|
|
140
|
+
interface OssService extends OssBaseOperation {
|
|
141
|
+
owner: string;
|
|
142
|
+
}
|
|
132
143
|
|
|
133
144
|
type OssBaseOptions<T = {
|
|
134
145
|
[key: string]: any;
|
|
@@ -206,6 +217,7 @@ declare class OssBase implements OssBaseOperation {
|
|
|
206
217
|
recursive?: boolean;
|
|
207
218
|
startAfter?: string;
|
|
208
219
|
maxKeys?: number;
|
|
220
|
+
getMeta?: boolean;
|
|
209
221
|
}): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]>;
|
|
210
222
|
/**
|
|
211
223
|
* 获取对象信息
|
|
@@ -260,6 +272,7 @@ declare class OssBase implements OssBaseOperation {
|
|
|
260
272
|
opts: Partial<OssBaseOptions<U>>;
|
|
261
273
|
}): T;
|
|
262
274
|
}
|
|
275
|
+
declare const getStram: (data: GetObjectCommandOutput) => Readable;
|
|
263
276
|
|
|
264
|
-
export { OssBase };
|
|
265
|
-
export type { OssBaseOptions };
|
|
277
|
+
export { OssBase, getStram };
|
|
278
|
+
export type { ItemBucketMetadata, ListDirectoryObject, ListFileObject, ListObjectResult, OssBaseOperation, OssBaseOptions, OssService, StatObjectResult, UploadedObjectInfo };
|
package/dist/index.js
CHANGED
|
@@ -36452,15 +36452,21 @@ class OssBase {
|
|
|
36452
36452
|
contentLength = Buffer.byteLength(putData);
|
|
36453
36453
|
}
|
|
36454
36454
|
} else {
|
|
36455
|
-
putData = data;
|
|
36456
36455
|
if (!contentLength) {
|
|
36457
|
-
|
|
36456
|
+
const chunks = [];
|
|
36457
|
+
for await (const chunk of data) {
|
|
36458
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
36459
|
+
}
|
|
36460
|
+
putData = Buffer.concat(chunks);
|
|
36461
|
+
contentLength = putData.length;
|
|
36462
|
+
} else {
|
|
36463
|
+
putData = data;
|
|
36458
36464
|
}
|
|
36459
36465
|
}
|
|
36460
36466
|
if (opts?.check) {
|
|
36461
36467
|
const obj = await this.statObject(objectName, true);
|
|
36462
36468
|
if (obj) {
|
|
36463
|
-
const omitMeta = ["size", "
|
|
36469
|
+
const omitMeta = ["size", "content-type", "cache-control", "app-source"];
|
|
36464
36470
|
const objMeta = JSON.parse(JSON.stringify(omit(obj.metaData, omitMeta)));
|
|
36465
36471
|
metaData = {
|
|
36466
36472
|
...objMeta,
|
|
@@ -36489,22 +36495,41 @@ class OssBase {
|
|
|
36489
36495
|
};
|
|
36490
36496
|
}
|
|
36491
36497
|
async fPutObject(objectName, filePath, metaData) {
|
|
36492
|
-
const fileStream = fs.createReadStream(filePath);
|
|
36493
36498
|
const stat = fs.statSync(filePath);
|
|
36494
36499
|
const { standardHeaders, customMetadata } = extractStandardHeaders(metaData || {});
|
|
36495
|
-
const
|
|
36496
|
-
|
|
36497
|
-
|
|
36498
|
-
|
|
36499
|
-
|
|
36500
|
-
|
|
36501
|
-
|
|
36502
|
-
|
|
36503
|
-
|
|
36504
|
-
|
|
36505
|
-
|
|
36506
|
-
|
|
36507
|
-
|
|
36500
|
+
const THRESHOLD = 5 * 1024 * 1024;
|
|
36501
|
+
let command;
|
|
36502
|
+
if (stat.size < THRESHOLD) {
|
|
36503
|
+
const fileBuffer = await fs.promises.readFile(filePath);
|
|
36504
|
+
command = new import_client_s3.PutObjectCommand({
|
|
36505
|
+
Bucket: this.bucketName,
|
|
36506
|
+
Key: `${this.prefix}${objectName}`,
|
|
36507
|
+
Body: fileBuffer,
|
|
36508
|
+
ContentLength: fileBuffer.length,
|
|
36509
|
+
ContentType: standardHeaders.ContentType || getContentType(filePath),
|
|
36510
|
+
CacheControl: standardHeaders.CacheControl,
|
|
36511
|
+
ContentDisposition: standardHeaders.ContentDisposition,
|
|
36512
|
+
ContentEncoding: standardHeaders.ContentEncoding,
|
|
36513
|
+
ContentLanguage: standardHeaders.ContentLanguage,
|
|
36514
|
+
Expires: standardHeaders.Expires,
|
|
36515
|
+
Metadata: customMetadata
|
|
36516
|
+
});
|
|
36517
|
+
} else {
|
|
36518
|
+
const fileStream = fs.createReadStream(filePath);
|
|
36519
|
+
command = new import_client_s3.PutObjectCommand({
|
|
36520
|
+
Bucket: this.bucketName,
|
|
36521
|
+
Key: `${this.prefix}${objectName}`,
|
|
36522
|
+
Body: fileStream,
|
|
36523
|
+
ContentLength: stat.size,
|
|
36524
|
+
ContentType: standardHeaders.ContentType || getContentType(filePath),
|
|
36525
|
+
CacheControl: standardHeaders.CacheControl,
|
|
36526
|
+
ContentDisposition: standardHeaders.ContentDisposition,
|
|
36527
|
+
ContentEncoding: standardHeaders.ContentEncoding,
|
|
36528
|
+
ContentLanguage: standardHeaders.ContentLanguage,
|
|
36529
|
+
Expires: standardHeaders.Expires,
|
|
36530
|
+
Metadata: customMetadata
|
|
36531
|
+
});
|
|
36532
|
+
}
|
|
36508
36533
|
const response = await this.client.send(command);
|
|
36509
36534
|
return {
|
|
36510
36535
|
etag: response.ETag?.replace(/"/g, "") || "",
|
|
@@ -36527,6 +36552,7 @@ class OssBase {
|
|
|
36527
36552
|
const prefix = `${this.prefix}${objectName}`;
|
|
36528
36553
|
const results = [];
|
|
36529
36554
|
let continuationToken;
|
|
36555
|
+
const getMeta = opts?.getMeta ?? false;
|
|
36530
36556
|
do {
|
|
36531
36557
|
const command = new import_client_s3.ListObjectsV2Command({
|
|
36532
36558
|
Bucket: this.bucketName,
|
|
@@ -36539,12 +36565,19 @@ class OssBase {
|
|
|
36539
36565
|
const response = await this.client.send(command);
|
|
36540
36566
|
if (response.Contents) {
|
|
36541
36567
|
for (const item of response.Contents) {
|
|
36542
|
-
|
|
36568
|
+
const result = {
|
|
36543
36569
|
name: item.Key || "",
|
|
36544
36570
|
size: item.Size || 0,
|
|
36545
36571
|
lastModified: item.LastModified || new Date,
|
|
36546
36572
|
etag: item.ETag?.replace(/"/g, "") || ""
|
|
36547
|
-
}
|
|
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);
|
|
36548
36581
|
}
|
|
36549
36582
|
}
|
|
36550
36583
|
if (response.CommonPrefixes && !opts?.recursive) {
|
|
@@ -36567,6 +36600,13 @@ class OssBase {
|
|
|
36567
36600
|
});
|
|
36568
36601
|
const response = await this.client.send(command);
|
|
36569
36602
|
return {
|
|
36603
|
+
standardHeaders: {
|
|
36604
|
+
contentType: response.ContentType,
|
|
36605
|
+
cacheControl: response.CacheControl,
|
|
36606
|
+
contentDisposition: response.ContentDisposition,
|
|
36607
|
+
contentEncoding: response.ContentEncoding,
|
|
36608
|
+
contentLanguage: response.ContentLanguage
|
|
36609
|
+
},
|
|
36570
36610
|
size: response.ContentLength || 0,
|
|
36571
36611
|
etag: response.ETag?.replace?.(/"/g, "") || "",
|
|
36572
36612
|
lastModified: response.LastModified || new Date,
|
|
@@ -36574,11 +36614,11 @@ class OssBase {
|
|
|
36574
36614
|
versionId: response.VersionId || null
|
|
36575
36615
|
};
|
|
36576
36616
|
} catch (e) {
|
|
36577
|
-
console.error("statObject error", e);
|
|
36578
36617
|
const isNotFound = e.name === "NotFound" || e.name === "NoSuchBucket" || e.name === "NoSuchKey" || e.code === "NotFound" || e.code === "NoSuchBucket" || e.code === "NoSuchKey" || e.$metadata?.httpStatusCode === 404;
|
|
36579
36618
|
if (checkFile && isNotFound) {
|
|
36580
36619
|
return null;
|
|
36581
36620
|
}
|
|
36621
|
+
console.error("statObject error", e);
|
|
36582
36622
|
throw e;
|
|
36583
36623
|
}
|
|
36584
36624
|
}
|
|
@@ -36659,6 +36699,13 @@ class OssBase {
|
|
|
36659
36699
|
});
|
|
36660
36700
|
}
|
|
36661
36701
|
}
|
|
36702
|
+
var getStram = (data) => {
|
|
36703
|
+
if (data.Body) {
|
|
36704
|
+
return data.Body;
|
|
36705
|
+
}
|
|
36706
|
+
throw new Error("Object body is empty");
|
|
36707
|
+
};
|
|
36662
36708
|
export {
|
|
36709
|
+
getStram,
|
|
36663
36710
|
OssBase
|
|
36664
36711
|
};
|
package/dist/services.d.ts
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
import * as _aws_sdk_client_s3 from '@aws-sdk/client-s3';
|
|
2
1
|
import { CopyObjectCommandOutput, S3Client, GetObjectCommandOutput } from '@aws-sdk/client-s3';
|
|
3
2
|
import { Readable } from 'node:stream';
|
|
4
|
-
import { ServerResponse } from 'node:http';
|
|
5
|
-
import { ItemBucketMetadata as ItemBucketMetadata$1, Client } from 'minio';
|
|
6
3
|
|
|
7
4
|
type ItemBucketMetadata = Record<string, string>;
|
|
8
|
-
type UploadedObjectInfo
|
|
5
|
+
type UploadedObjectInfo = {
|
|
9
6
|
etag: string;
|
|
10
7
|
lastModified?: Date;
|
|
11
8
|
size?: number;
|
|
12
9
|
versionId: string;
|
|
13
10
|
metadata?: ItemBucketMetadata;
|
|
14
11
|
};
|
|
15
|
-
type StatObjectResult
|
|
12
|
+
type StatObjectResult = {
|
|
16
13
|
size: number;
|
|
17
14
|
etag: string;
|
|
18
15
|
lastModified: Date;
|
|
19
16
|
metaData: ItemBucketMetadata;
|
|
20
17
|
versionId?: string | null;
|
|
18
|
+
standardHeaders: {
|
|
19
|
+
contentType?: string;
|
|
20
|
+
cacheControl?: string;
|
|
21
|
+
contentDisposition?: string;
|
|
22
|
+
contentEncoding?: string;
|
|
23
|
+
contentLanguage?: string;
|
|
24
|
+
};
|
|
21
25
|
};
|
|
22
|
-
type ListFileObject
|
|
26
|
+
type ListFileObject = {
|
|
23
27
|
name: string;
|
|
24
28
|
size: number;
|
|
25
29
|
lastModified: Date;
|
|
26
30
|
etag: string;
|
|
31
|
+
metaData?: ItemBucketMetadata;
|
|
27
32
|
};
|
|
28
|
-
type ListDirectoryObject
|
|
33
|
+
type ListDirectoryObject = {
|
|
29
34
|
prefix: string;
|
|
30
35
|
size: number;
|
|
31
36
|
};
|
|
32
|
-
type ListObjectResult
|
|
33
|
-
interface OssBaseOperation
|
|
37
|
+
type ListObjectResult = ListFileObject | ListDirectoryObject;
|
|
38
|
+
interface OssBaseOperation {
|
|
34
39
|
prefix: string;
|
|
35
40
|
/**
|
|
36
41
|
* 设置前缀
|
|
@@ -64,20 +69,20 @@ interface OssBaseOperation$1 {
|
|
|
64
69
|
isStream?: boolean;
|
|
65
70
|
size?: number;
|
|
66
71
|
contentType?: string;
|
|
67
|
-
}): Promise<UploadedObjectInfo
|
|
72
|
+
}): Promise<UploadedObjectInfo>;
|
|
68
73
|
/**
|
|
69
74
|
* 上传文件
|
|
70
75
|
* @param objectName 对象名
|
|
71
76
|
* @param filePath 文件路径
|
|
72
77
|
* @param metaData 元数据
|
|
73
78
|
*/
|
|
74
|
-
fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo
|
|
79
|
+
fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
|
|
75
80
|
/**
|
|
76
81
|
* 获取对象信息
|
|
77
82
|
* @param objectName 对象名
|
|
78
83
|
* @param checkFile 是否检查文件存在(不存在返回null而非抛错)
|
|
79
84
|
*/
|
|
80
|
-
statObject(objectName: string, checkFile?: boolean): Promise<StatObjectResult
|
|
85
|
+
statObject(objectName: string, checkFile?: boolean): Promise<StatObjectResult | null>;
|
|
81
86
|
/**
|
|
82
87
|
* 删除对象
|
|
83
88
|
* @param objectName 对象名
|
|
@@ -95,7 +100,7 @@ interface OssBaseOperation$1 {
|
|
|
95
100
|
startAfter?: string;
|
|
96
101
|
/** 最大返回数量 */
|
|
97
102
|
maxKeys?: number;
|
|
98
|
-
}): Promise<ListObjectResult
|
|
103
|
+
}): Promise<ListObjectResult[]>;
|
|
99
104
|
/**
|
|
100
105
|
* 获取完整的对象名称
|
|
101
106
|
* @param objectName 对象名
|
|
@@ -110,7 +115,7 @@ interface OssBaseOperation$1 {
|
|
|
110
115
|
checkObjectHash?(objectName: string, hash: string, meta?: ItemBucketMetadata): Promise<{
|
|
111
116
|
success: boolean;
|
|
112
117
|
metaData: ItemBucketMetadata | null;
|
|
113
|
-
obj: StatObjectResult
|
|
118
|
+
obj: StatObjectResult | null;
|
|
114
119
|
equalMeta?: boolean;
|
|
115
120
|
}>;
|
|
116
121
|
/**
|
|
@@ -132,7 +137,7 @@ interface OssBaseOperation$1 {
|
|
|
132
137
|
*/
|
|
133
138
|
replaceObject?(objectName: string, meta: ItemBucketMetadata): Promise<any>;
|
|
134
139
|
}
|
|
135
|
-
interface OssService
|
|
140
|
+
interface OssService extends OssBaseOperation {
|
|
136
141
|
owner: string;
|
|
137
142
|
}
|
|
138
143
|
|
|
@@ -152,7 +157,7 @@ type OssBaseOptions<T = {
|
|
|
152
157
|
*/
|
|
153
158
|
prefix?: string;
|
|
154
159
|
} & T;
|
|
155
|
-
declare class OssBase implements OssBaseOperation
|
|
160
|
+
declare class OssBase implements OssBaseOperation {
|
|
156
161
|
client: S3Client;
|
|
157
162
|
bucketName: string;
|
|
158
163
|
prefix: string;
|
|
@@ -189,14 +194,14 @@ declare class OssBase implements OssBaseOperation$1 {
|
|
|
189
194
|
isStream?: boolean;
|
|
190
195
|
size?: number;
|
|
191
196
|
contentType?: string;
|
|
192
|
-
}): Promise<UploadedObjectInfo
|
|
197
|
+
}): Promise<UploadedObjectInfo>;
|
|
193
198
|
/**
|
|
194
199
|
* 上传文件
|
|
195
200
|
* @param objectName 对象名
|
|
196
201
|
* @param filePath 文件路径
|
|
197
202
|
* @param metaData 元数据
|
|
198
203
|
*/
|
|
199
|
-
fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo
|
|
204
|
+
fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
|
|
200
205
|
/**
|
|
201
206
|
* 删除对象
|
|
202
207
|
* @param objectName 对象名
|
|
@@ -212,13 +217,14 @@ declare class OssBase implements OssBaseOperation$1 {
|
|
|
212
217
|
recursive?: boolean;
|
|
213
218
|
startAfter?: string;
|
|
214
219
|
maxKeys?: number;
|
|
215
|
-
|
|
220
|
+
getMeta?: boolean;
|
|
221
|
+
}): Promise<IS_FILE extends true ? ListFileObject[] : ListObjectResult[]>;
|
|
216
222
|
/**
|
|
217
223
|
* 获取对象信息
|
|
218
224
|
* @param objectName 对象名
|
|
219
225
|
* @param checkFile 是否检查文件存在(不存在返回null而非抛错)
|
|
220
226
|
*/
|
|
221
|
-
statObject(objectName: string, checkFile?: boolean): Promise<StatObjectResult
|
|
227
|
+
statObject(objectName: string, checkFile?: boolean): Promise<StatObjectResult | null>;
|
|
222
228
|
/**
|
|
223
229
|
* 获取完整的对象名称
|
|
224
230
|
* @param objectName 对象名
|
|
@@ -233,7 +239,7 @@ declare class OssBase implements OssBaseOperation$1 {
|
|
|
233
239
|
checkObjectHash(objectName: string, hash: string, meta?: ItemBucketMetadata): Promise<{
|
|
234
240
|
success: boolean;
|
|
235
241
|
metaData: ItemBucketMetadata | null;
|
|
236
|
-
obj: StatObjectResult
|
|
242
|
+
obj: StatObjectResult | null;
|
|
237
243
|
equalMeta?: boolean;
|
|
238
244
|
}>;
|
|
239
245
|
/**
|
|
@@ -267,18 +273,18 @@ declare class OssBase implements OssBaseOperation$1 {
|
|
|
267
273
|
}): T;
|
|
268
274
|
}
|
|
269
275
|
|
|
270
|
-
declare class ConfigOssService extends OssBase implements OssService
|
|
276
|
+
declare class ConfigOssService extends OssBase implements OssService {
|
|
271
277
|
owner: string;
|
|
272
278
|
constructor(opts: OssBaseOptions<{
|
|
273
279
|
owner: string;
|
|
274
280
|
}>);
|
|
275
|
-
listAllFile(): Promise<ListFileObject
|
|
276
|
-
listAll(): Promise<ListObjectResult
|
|
281
|
+
listAllFile(): Promise<ListFileObject[]>;
|
|
282
|
+
listAll(): Promise<ListObjectResult[]>;
|
|
277
283
|
configMap: Map<string, any>;
|
|
278
284
|
keys: string[];
|
|
279
|
-
getAllConfigJson(): Promise<ListFileObject
|
|
285
|
+
getAllConfigJson(): Promise<ListFileObject[]>;
|
|
280
286
|
isEndWithJson(string: string): boolean;
|
|
281
|
-
putJsonObject(key: string, data: any): Promise<UploadedObjectInfo
|
|
287
|
+
putJsonObject(key: string, data: any): Promise<UploadedObjectInfo>;
|
|
282
288
|
getObjectList(objectNameList: string[]): Promise<Map<string, Record<string, any>>>;
|
|
283
289
|
getList(): Promise<{
|
|
284
290
|
list: {
|
|
@@ -287,31 +293,13 @@ declare class ConfigOssService extends OssBase implements OssService$1 {
|
|
|
287
293
|
size: number;
|
|
288
294
|
lastModified: Date;
|
|
289
295
|
etag: string;
|
|
296
|
+
metaData?: ItemBucketMetadata;
|
|
290
297
|
}[];
|
|
291
298
|
keys: string[];
|
|
292
299
|
keyEtagMap: Map<string, string>;
|
|
293
300
|
}>;
|
|
294
301
|
}
|
|
295
302
|
|
|
296
|
-
/**
|
|
297
|
-
* 过滤 metaData 中的 key, 去除 password, accesskey, secretkey,
|
|
298
|
-
* 并返回过滤后的 metaData
|
|
299
|
-
* @param metaData
|
|
300
|
-
* @returns
|
|
301
|
-
*/
|
|
302
|
-
declare const filterMetaDataKeys: (metaData: Record<string, string>, clearKeys?: string[]) => Record<string, string>;
|
|
303
|
-
type SendObjectOptions = {
|
|
304
|
-
res: ServerResponse;
|
|
305
|
-
client: OssBase;
|
|
306
|
-
objectName: string;
|
|
307
|
-
isDownload?: boolean;
|
|
308
|
-
};
|
|
309
|
-
declare const NotFoundFile: (res: ServerResponse, msg?: string, code?: number) => void;
|
|
310
|
-
declare const sendObject: ({ res, objectName, client, isDownload }: SendObjectOptions) => Promise<void>;
|
|
311
|
-
declare const downloadObject: ({ objectName, client, filePath }: Pick<SendObjectOptions, "objectName" | "client"> & {
|
|
312
|
-
filePath: string;
|
|
313
|
-
}) => Promise<_aws_sdk_client_s3.GetObjectCommandOutput>;
|
|
314
|
-
|
|
315
303
|
/**
|
|
316
304
|
* 计算字符串的md5值
|
|
317
305
|
* @param str
|
|
@@ -341,88 +329,5 @@ declare function extractStandardHeaders(metaData: Record<string, string>): {
|
|
|
341
329
|
customMetadata: Record<string, string>;
|
|
342
330
|
};
|
|
343
331
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
lastModified?: Date;
|
|
347
|
-
size?: number;
|
|
348
|
-
versionId: string;
|
|
349
|
-
metadata?: ItemBucketMetadata$1;
|
|
350
|
-
};
|
|
351
|
-
type StatObjectResult = {
|
|
352
|
-
size: number;
|
|
353
|
-
etag: string;
|
|
354
|
-
lastModified: Date;
|
|
355
|
-
metaData: ItemBucketMetadata$1;
|
|
356
|
-
versionId?: string | null;
|
|
357
|
-
};
|
|
358
|
-
type ListFileObject = {
|
|
359
|
-
name: string;
|
|
360
|
-
size: number;
|
|
361
|
-
lastModified: Date;
|
|
362
|
-
etag: string;
|
|
363
|
-
};
|
|
364
|
-
type ListDirectoryObject = {
|
|
365
|
-
prefix: string;
|
|
366
|
-
size: number;
|
|
367
|
-
};
|
|
368
|
-
type ListObjectResult = ListFileObject | ListDirectoryObject;
|
|
369
|
-
interface OssBaseOperation {
|
|
370
|
-
prefix: string;
|
|
371
|
-
setPrefix(prefix: string): void;
|
|
372
|
-
/**
|
|
373
|
-
* 获取对象
|
|
374
|
-
* @param objectName 对象名
|
|
375
|
-
*/
|
|
376
|
-
getObject(objectName: string): Promise<any>;
|
|
377
|
-
/**
|
|
378
|
-
* 上传对象
|
|
379
|
-
* @param objectName 对象名
|
|
380
|
-
* @param data 数据
|
|
381
|
-
*/
|
|
382
|
-
putObject(objectName: string, data: Buffer | string, metaData?: ItemBucketMetadata$1): Promise<UploadedObjectInfo>;
|
|
383
|
-
/**
|
|
384
|
-
* 上传文件
|
|
385
|
-
* @param objectName 对象名
|
|
386
|
-
* @param filePath 文件路径
|
|
387
|
-
*/
|
|
388
|
-
fPutObject(objectName: string, filePath: string, metaData?: ItemBucketMetadata$1): Promise<UploadedObjectInfo>;
|
|
389
|
-
/**
|
|
390
|
-
* 获取对象信息
|
|
391
|
-
* @param objectName 对象名
|
|
392
|
-
*/
|
|
393
|
-
statObject(objectName: string): Promise<StatObjectResult>;
|
|
394
|
-
/**
|
|
395
|
-
* 删除对象
|
|
396
|
-
* @param objectName 对象名
|
|
397
|
-
*/
|
|
398
|
-
deleteObject(objectName: string): Promise<any>;
|
|
399
|
-
/**
|
|
400
|
-
* 列出对象
|
|
401
|
-
* @param objectName 对象名
|
|
402
|
-
* @param opts 选项
|
|
403
|
-
* @param opts.recursive 是否递归
|
|
404
|
-
* @param opts.startAfter 开始位置
|
|
405
|
-
*/
|
|
406
|
-
listObjects(objectName: string, opts?: {
|
|
407
|
-
/**
|
|
408
|
-
* 是否递归
|
|
409
|
-
*/
|
|
410
|
-
recursive?: boolean;
|
|
411
|
-
/**
|
|
412
|
-
* 开始位置
|
|
413
|
-
*/
|
|
414
|
-
startAfter?: string;
|
|
415
|
-
}): Promise<ListObjectResult[]>;
|
|
416
|
-
/**
|
|
417
|
-
* 复制对象
|
|
418
|
-
* @param sourceObject 源对象
|
|
419
|
-
* @param targetObject 目标对象
|
|
420
|
-
*/
|
|
421
|
-
copyObject: Client['copyObject'];
|
|
422
|
-
}
|
|
423
|
-
interface OssService extends OssBaseOperation {
|
|
424
|
-
owner: string;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
export { ConfigOssService, NotFoundFile, OssBase, downloadObject, extractStandardHeaders, filterMetaDataKeys, getContentType, hash, hashSringify, sendObject, standardHeaderKeys };
|
|
428
|
-
export type { ListDirectoryObject, ListFileObject, ListObjectResult, OssBaseOperation, OssBaseOptions, OssService, StandardHeaders, StatObjectResult, UploadedObjectInfo };
|
|
332
|
+
export { ConfigOssService, OssBase, extractStandardHeaders, getContentType, hash, hashSringify, standardHeaderKeys };
|
|
333
|
+
export type { ItemBucketMetadata, ListDirectoryObject, ListFileObject, ListObjectResult, OssBaseOperation, OssBaseOptions, OssService, StandardHeaders, StatObjectResult, UploadedObjectInfo };
|