fsd-oss 0.13.1 → 0.13.2
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/lib/simple-oss-client.js +20 -5
- package/package.json +2 -2
- package/simple-oss-client.d.ts +1 -0
package/lib/simple-oss-client.js
CHANGED
|
@@ -57,6 +57,7 @@ class SimpleOSSClient {
|
|
|
57
57
|
let query = {
|
|
58
58
|
'list-type': '2'
|
|
59
59
|
};
|
|
60
|
+
let subres = {};
|
|
60
61
|
if (options.prefix)
|
|
61
62
|
query.prefix = options.prefix;
|
|
62
63
|
if (options.delimiter)
|
|
@@ -64,14 +65,15 @@ class SimpleOSSClient {
|
|
|
64
65
|
if (options.startAfter)
|
|
65
66
|
query['start-after'] = options.startAfter;
|
|
66
67
|
if (options.continuationToken)
|
|
67
|
-
|
|
68
|
+
subres['continuation-token'] = options.continuationToken;
|
|
68
69
|
if (options.maxKeys)
|
|
69
|
-
query['max-keys'] = options.maxKeys;
|
|
70
|
+
query['max-keys'] = String(options.maxKeys);
|
|
70
71
|
if (options.encodingType)
|
|
71
72
|
query['encoding-type'] = options.encodingType;
|
|
72
73
|
if (options.fetchOwner)
|
|
73
|
-
query['fetch-owner'] = options.fetchOwner;
|
|
74
|
+
query['fetch-owner'] = String(options.fetchOwner);
|
|
74
75
|
options.query = query;
|
|
76
|
+
options.subres = subres;
|
|
75
77
|
let res = await this.requestData('GET', '', null, options);
|
|
76
78
|
res.KeyCount = parseInt(res.KeyCount);
|
|
77
79
|
res.MaxKeys = parseInt(res.MaxKeys);
|
|
@@ -147,12 +149,14 @@ class SimpleOSSClient {
|
|
|
147
149
|
if (this.config.stsToken) {
|
|
148
150
|
headers['x-oss-security-token'] = this.config.stsToken;
|
|
149
151
|
}
|
|
150
|
-
|
|
152
|
+
let canonicalizedResource = this.createCanonicalizedResource(`/${this.config.bucket}/${resource}`, options.subres);
|
|
153
|
+
headers.authorization = this.getSign(method, canonicalizedResource, headers);
|
|
151
154
|
let url = `https://${this.config.bucket}.${this.endpoint}/${resource}`;
|
|
155
|
+
let query = Object.assign({}, options.query, options.subres);
|
|
152
156
|
return client.request(url, {
|
|
153
157
|
method,
|
|
154
158
|
headers,
|
|
155
|
-
query
|
|
159
|
+
query,
|
|
156
160
|
body,
|
|
157
161
|
timeout: options.timeout || this.config.timeout || 60000
|
|
158
162
|
});
|
|
@@ -201,6 +205,17 @@ class SimpleOSSClient {
|
|
|
201
205
|
query.Expires = expires;
|
|
202
206
|
return `${url}?${qs.stringify(query)}`;
|
|
203
207
|
}
|
|
208
|
+
createCanonicalizedResource(resource, subres) {
|
|
209
|
+
if (!subres)
|
|
210
|
+
return resource;
|
|
211
|
+
let string = Object.keys(subres)
|
|
212
|
+
.sort()
|
|
213
|
+
.map((key) => `${key}=${subres[key]}`)
|
|
214
|
+
.join('&');
|
|
215
|
+
if (string)
|
|
216
|
+
return `${resource}?${string}`;
|
|
217
|
+
return resource;
|
|
218
|
+
}
|
|
204
219
|
getSign(method, canonicalizedResource, headers) {
|
|
205
220
|
headers = headers || {};
|
|
206
221
|
let parts = [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fsd-oss",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Aliyun OSS adapter for fsd",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"slash": "^3.0.0",
|
|
23
23
|
"xml2js": "^0.6.2"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "f5aaaca713f514d3a8fb65bc2eecd1e8df8fd5c8"
|
|
26
26
|
}
|