mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: http校验方式,支持七牛云oss、阿里云oss、腾讯云cos
This commit is contained in:
@@ -1,10 +1,28 @@
|
||||
import { BaseHttpChallengeUploader } from "../api.js";
|
||||
import { TencentCosAccess } from "@certd/plugin-lib/dist/tencent/access-cos";
|
||||
import { TencentAccess, TencentCosAccess, TencentCosClient } from "@certd/plugin-lib";
|
||||
|
||||
export class TencentCosHttpChallengeUploader extends BaseHttpChallengeUploader<TencentCosAccess> {
|
||||
async upload(fileName: string, fileContent: string) {
|
||||
return null;
|
||||
async upload(filePath: string, fileContent: Buffer) {
|
||||
const access = await this.ctx.accessService.getById<TencentAccess>(this.access.accessId);
|
||||
const client = new TencentCosClient({
|
||||
access: access,
|
||||
logger: this.logger,
|
||||
region: this.access.region,
|
||||
bucket: this.access.bucket,
|
||||
});
|
||||
const key = this.rootDir + filePath;
|
||||
await client.uploadFile(key, fileContent);
|
||||
}
|
||||
|
||||
async remove(fileName: string) {}
|
||||
async remove(filePath: string) {
|
||||
const access = await this.ctx.accessService.getById<TencentAccess>(this.access.accessId);
|
||||
const client = new TencentCosClient({
|
||||
access: access,
|
||||
logger: this.logger,
|
||||
region: this.access.region,
|
||||
bucket: this.access.bucket,
|
||||
});
|
||||
const key = this.rootDir + filePath;
|
||||
await client.removeFile(key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user