mirror of
https://github.com/certd/certd.git
synced 2026-04-16 05:50:50 +08:00
perf: http校验方式支持scp上传
This commit is contained in:
@@ -23,6 +23,9 @@ export class OssClientFactory {
|
||||
} else if (type === "s3") {
|
||||
const module = await import("./impls/s3.js");
|
||||
return module.default;
|
||||
} else if (type === "scp") {
|
||||
const module = await import("./impls/scp.js");
|
||||
return module.default;
|
||||
} else {
|
||||
throw new Error(`暂不支持此文件上传方式: ${type}`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import SftpOssClientImpl from "./sftp.js";
|
||||
|
||||
export default class ScpOssClientImpl extends SftpOssClientImpl {
|
||||
getUploaderType() {
|
||||
return 'scp';
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import fs from "fs";
|
||||
import { SftpAccess, SshAccess, SshClient } from "../../ssh/index.js";
|
||||
|
||||
export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
||||
getUploaderType() {
|
||||
return 'sftp';
|
||||
}
|
||||
async download(fileName: string, savePath: string): Promise<void> {
|
||||
const path = this.join(this.rootDir, fileName);
|
||||
const client = new SshClient(this.logger);
|
||||
@@ -48,6 +51,7 @@ export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
||||
const key = this.join(this.rootDir, filePath);
|
||||
try {
|
||||
const client = new SshClient(this.logger);
|
||||
const uploaderType = this.getUploaderType();
|
||||
await client.uploadFiles({
|
||||
connectConf: access,
|
||||
mkdirs: true,
|
||||
@@ -57,7 +61,7 @@ export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
||||
remotePath: key,
|
||||
},
|
||||
],
|
||||
uploadType: "sftp",
|
||||
uploadType: uploaderType,
|
||||
opts: {
|
||||
mode: this.access?.fileMode ?? undefined,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user