mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
perf: 支持s3 access做测试
This commit is contained in:
@@ -54,6 +54,9 @@ export default class S3OssClientImpl extends BaseOssClient<S3Access> {
|
||||
Prefix: dirKey, // The name of the object. For example, 'sample_upload.txt'.
|
||||
};
|
||||
const res = await this.client.send(new ListObjectsCommand({ ...params }));
|
||||
if (!res.Contents) {
|
||||
return [];
|
||||
}
|
||||
return res.Contents.map(item => {
|
||||
return {
|
||||
path: item.Key,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { AccessInput, BaseAccess, IsAccess } from "@certd/pipeline";
|
||||
import { ossClientFactory } from "../oss/index.js";
|
||||
import S3OssClientImpl from "../oss/impls/s3.js";
|
||||
|
||||
/**
|
||||
* 这个注解将注册一个授权配置
|
||||
@@ -82,6 +84,32 @@ export class S3Access extends BaseAccess {
|
||||
required: true,
|
||||
})
|
||||
bucket!: string;
|
||||
|
||||
@AccessInput({
|
||||
title: "测试",
|
||||
component: {
|
||||
name: "api-test",
|
||||
action: "TestRequest",
|
||||
},
|
||||
helper: "点击测试接口是否正常",
|
||||
})
|
||||
testRequest = true;
|
||||
|
||||
async onTestRequest() {
|
||||
const client: S3OssClientImpl = await ossClientFactory.createOssClientByType("s3", {
|
||||
access: this,
|
||||
rootDir: "",
|
||||
ctx: {
|
||||
accessService: this.ctx.accessService,
|
||||
logger: this.ctx.logger,
|
||||
utils: this.ctx.utils,
|
||||
},
|
||||
});
|
||||
|
||||
await client.listDir("/");
|
||||
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
|
||||
new S3Access();
|
||||
|
||||
Reference in New Issue
Block a user