mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
perf: http校验方式,支持七牛云oss、阿里云oss、腾讯云cos
This commit is contained in:
@@ -3,7 +3,7 @@ import { AliossAccess, AliyunAccess } from "@certd/plugin-lib";
|
||||
import { AliossClient } from "@certd/plugin-lib";
|
||||
|
||||
export class AliossHttpChallengeUploader extends BaseHttpChallengeUploader<AliossAccess> {
|
||||
async upload(filePath: string, fileContent: string) {
|
||||
async upload(filePath: string, fileContent: Buffer) {
|
||||
const aliyunAccess = await this.ctx.accessService.getById<AliyunAccess>(this.access.accessId);
|
||||
const client = new AliossClient({
|
||||
access: aliyunAccess,
|
||||
@@ -11,16 +11,19 @@ export class AliossHttpChallengeUploader extends BaseHttpChallengeUploader<Alios
|
||||
region: this.access.region,
|
||||
});
|
||||
|
||||
await client.uploadFile(filePath, Buffer.from(fileContent));
|
||||
const key = this.rootDir + filePath;
|
||||
this.logger.info(`开始上传文件: ${key}`);
|
||||
await client.uploadFile(key, fileContent);
|
||||
|
||||
this.logger.info(`校验文件上传成功: ${filePath}`);
|
||||
}
|
||||
|
||||
async remove(filePath: string) {
|
||||
const key = this.rootDir + filePath;
|
||||
// remove file from alioss
|
||||
const client = await this.getAliossClient();
|
||||
await client.removeFile(filePath);
|
||||
this.logger.info(`文件删除成功: ${filePath}`);
|
||||
await client.removeFile(key);
|
||||
this.logger.info(`文件删除成功: ${key}`);
|
||||
}
|
||||
|
||||
private async getAliossClient() {
|
||||
|
||||
Reference in New Issue
Block a user