mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: http校验方式支持scp上传
This commit is contained in:
@@ -20,6 +20,7 @@ export const Dicts = {
|
|||||||
uploaderTypeDict: dict({
|
uploaderTypeDict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ label: "SFTP", value: "sftp" },
|
{ label: "SFTP", value: "sftp" },
|
||||||
|
{ label: "SCP", value: "scp" },
|
||||||
{ label: "FTP", value: "ftp" },
|
{ label: "FTP", value: "ftp" },
|
||||||
{ label: "阿里云OSS", value: "alioss" },
|
{ label: "阿里云OSS", value: "alioss" },
|
||||||
{ label: "腾讯云COS", value: "tencentcos" },
|
{ label: "腾讯云COS", value: "tencentcos" },
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ export class OssClientFactory {
|
|||||||
} else if (type === "s3") {
|
} else if (type === "s3") {
|
||||||
const module = await import("./impls/s3.js");
|
const module = await import("./impls/s3.js");
|
||||||
return module.default;
|
return module.default;
|
||||||
|
} else if (type === "scp") {
|
||||||
|
const module = await import("./impls/scp.js");
|
||||||
|
return module.default;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`暂不支持此文件上传方式: ${type}`);
|
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";
|
import { SftpAccess, SshAccess, SshClient } from "../../ssh/index.js";
|
||||||
|
|
||||||
export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
||||||
|
getUploaderType() {
|
||||||
|
return 'sftp';
|
||||||
|
}
|
||||||
async download(fileName: string, savePath: string): Promise<void> {
|
async download(fileName: string, savePath: string): Promise<void> {
|
||||||
const path = this.join(this.rootDir, fileName);
|
const path = this.join(this.rootDir, fileName);
|
||||||
const client = new SshClient(this.logger);
|
const client = new SshClient(this.logger);
|
||||||
@@ -48,6 +51,7 @@ export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
|||||||
const key = this.join(this.rootDir, filePath);
|
const key = this.join(this.rootDir, filePath);
|
||||||
try {
|
try {
|
||||||
const client = new SshClient(this.logger);
|
const client = new SshClient(this.logger);
|
||||||
|
const uploaderType = this.getUploaderType();
|
||||||
await client.uploadFiles({
|
await client.uploadFiles({
|
||||||
connectConf: access,
|
connectConf: access,
|
||||||
mkdirs: true,
|
mkdirs: true,
|
||||||
@@ -57,7 +61,7 @@ export default class SftpOssClientImpl extends BaseOssClient<SftpAccess> {
|
|||||||
remotePath: key,
|
remotePath: key,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
uploadType: "sftp",
|
uploadType: uploaderType,
|
||||||
opts: {
|
opts: {
|
||||||
mode: this.access?.fileMode ?? undefined,
|
mode: this.access?.fileMode ?? undefined,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user