perf: http校验方式支持scp上传

This commit is contained in:
xiaojunnuo
2026-02-15 13:16:16 +08:00
parent 61800b23e2
commit 4eb940ffe7
4 changed files with 16 additions and 1 deletions

View File

@@ -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}`);
}

View File

@@ -0,0 +1,7 @@
import SftpOssClientImpl from "./sftp.js";
export default class ScpOssClientImpl extends SftpOssClientImpl {
getUploaderType() {
return 'scp';
}
}

View File

@@ -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,
},