Skip to content

Commit ffcfeb0

Browse files
committed
updatye: 提供 COS.util,更新 d.ts
1 parent 39930fc commit ffcfeb0

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

index.d.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ declare namespace COS {
191191
) => void,
192192
}
193193

194+
type StringOrBuffer = Buffer | String;
195+
interface Util {
196+
md5: (StringOrBuffer) => string,
197+
xml2json: (string) => string,
198+
json2xml: (string) => string,
199+
}
200+
194201
interface StaticGetAuthorizationOptions {
195202
/** 计算签名用的密钥 SecretId,必选 */
196203
SecretId: string,
@@ -217,6 +224,7 @@ declare namespace COS {
217224
/** 校正时间的偏移值,单位 ms(毫秒),计算签名时会用设备当前时间戳加上该偏移值,在设备时间有误时可用于校正签名用的时间参数。 */
218225
SystemClockOffset?: number,
219226
}
227+
220228
/** 计算签名或获取临时密钥可能需要的参数列表 */
221229
interface GetAuthorizationOptions {
222230
/** 存储桶的名称,格式为<bucketname-appid>,例如examplebucket-1250000000 */
@@ -1832,9 +1840,11 @@ Bulk:批量模式,恢复时间为24 - 48小时。 */
18321840

18331841
// request
18341842
/** request 接口参数 */
1835-
interface RequestParams extends ObjectParams {
1843+
interface RequestParams extends BucketParams {
18361844
/** 操作方法,如 get,post,delete, head 等 HTTP 方法 */
18371845
Method: string,
1846+
/** 请求的对象键,最前面不带 / */
1847+
Key?: Key,
18381848
/** 请求里的 Url Query 参数 */
18391849
Query?: Query,
18401850
/** 请求里的 Body 参数 */
@@ -1843,7 +1853,9 @@ Bulk:批量模式,恢复时间为24 - 48小时。 */
18431853
Action: Action
18441854
}
18451855
/** Request 接口返回值 */
1846-
interface RequestResult extends GeneralResult {}
1856+
interface RequestResult extends GeneralResult {
1857+
Body?: Buffer,
1858+
}
18471859

18481860
// getObjectUrl
18491861
/** getObjectUrl 接口参数 */
@@ -1920,6 +1932,9 @@ declare class COS {
19201932
/** 计算签名 */
19211933
static getAuthorization: (options: COS.StaticGetAuthorizationOptions) => string;
19221934

1935+
/** 工具 */
1936+
static util: COS.Util;
1937+
19231938
// 实例方法
19241939
/** 获取用户的 bucket 列表 @see https://cloud.tencent.com/document/product/436/8291 */
19251940
getService(params: COS.GetServiceParams, callback: (err: COS.CosError, data: COS.GetServiceResult) => void): void;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-nodejs-sdk-v5",
3-
"version": "2.10.3",
3+
"version": "2.10.4",
44
"description": "cos nodejs sdk v5",
55
"main": "index.js",
66
"types": "index.d.ts",

sdk/cos.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ var COS = function (options) {
7070
base.init(COS, task);
7171
advance.init(COS, task);
7272

73+
COS.util = {
74+
md5: util.md5,
75+
xml2json: util.xml2json,
76+
json2xml: util.json2xml,
77+
};
7378
COS.getAuthorization = util.getAuth;
7479
COS.version = pkg.version;
7580

0 commit comments

Comments
 (0)