@cloudbase/manager-node 4.10.4 → 4.10.5
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/storage/index.js +6 -10
- package/package.json +1 -1
- package/types/storage/index.d.ts +17 -3
package/lib/storage/index.js
CHANGED
|
@@ -617,21 +617,17 @@ class StorageService {
|
|
|
617
617
|
Error
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
|
-
|
|
621
|
-
* 获取文件存储权限
|
|
622
|
-
* READONLY:所有用户可读,仅创建者和管理员可写
|
|
623
|
-
* PRIVATE:仅创建者及管理员可读写
|
|
624
|
-
* ADMINWRITE:所有用户可读,仅管理员可写
|
|
625
|
-
* ADMINONLY:仅管理员可读写
|
|
626
|
-
* CUSTOM:自定义安全规则
|
|
627
|
-
* @returns {Promise<{ acl: AclType, rule?: IStorageAclRule }>}
|
|
628
|
-
*/
|
|
629
|
-
async getStorageAcl() {
|
|
620
|
+
async getStorageAcl(options) {
|
|
630
621
|
const { bucket, env } = this.getStorageConfig();
|
|
631
622
|
const res = await this.tcbService.request('DescribeStorageSafeRule', {
|
|
632
623
|
EnvId: env,
|
|
633
624
|
Bucket: bucket
|
|
634
625
|
});
|
|
626
|
+
// 默认行为:返回简单的 AclType(向后兼容)
|
|
627
|
+
if (!(options === null || options === void 0 ? void 0 : options.withRule)) {
|
|
628
|
+
return res.AclTag;
|
|
629
|
+
}
|
|
630
|
+
// 带规则模式:返回对象
|
|
635
631
|
const result = { acl: res.AclTag };
|
|
636
632
|
if (res.AclTag === 'CUSTOM' && res.Rule) {
|
|
637
633
|
try {
|
package/package.json
CHANGED
package/types/storage/index.d.ts
CHANGED
|
@@ -227,9 +227,23 @@ export declare class StorageService {
|
|
|
227
227
|
* ADMINWRITE:所有用户可读,仅管理员可写
|
|
228
228
|
* ADMINONLY:仅管理员可读写
|
|
229
229
|
* CUSTOM:自定义安全规则
|
|
230
|
-
*
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
*
|
|
231
|
+
* @param options.withRule 是否返回自定义安全规则,默认 false 以保持向后兼容
|
|
232
|
+
* @returns 不传参数时返回 AclType(向后兼容),传入 { withRule: true } 时返回 { acl: AclType, rule?: IStorageAclRule }
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* // 向后兼容的简单用法(返回 AclType)
|
|
236
|
+
* const acl = await storage.getStorageAcl()
|
|
237
|
+
* if (acl === 'READONLY') { ... }
|
|
238
|
+
*
|
|
239
|
+
* // 获取自定义安全规则(返回对象)
|
|
240
|
+
* const result = await storage.getStorageAcl({ withRule: true })
|
|
241
|
+
* console.log(result.acl, result.rule)
|
|
242
|
+
*/
|
|
243
|
+
getStorageAcl(): Promise<AclType>;
|
|
244
|
+
getStorageAcl(options: {
|
|
245
|
+
withRule: true;
|
|
246
|
+
}): Promise<{
|
|
233
247
|
acl: AclType;
|
|
234
248
|
rule?: IStorageAclRule;
|
|
235
249
|
}>;
|