2025-01-03 00:12:15 +08:00
|
|
|
import { BaseHttpChallengeUploader } from "../api.js";
|
|
|
|
|
import { FtpAccess, FtpClient } from "@certd/plugin-lib";
|
2025-01-02 00:28:13 +08:00
|
|
|
|
|
|
|
|
export class FtpHttpChallengeUploader extends BaseHttpChallengeUploader<FtpAccess> {
|
|
|
|
|
async upload(fileName: string, fileContent: string) {
|
|
|
|
|
const client = new FtpClient({
|
|
|
|
|
access: this.access,
|
|
|
|
|
logger: this.logger,
|
|
|
|
|
});
|
|
|
|
|
await client.connect(async (client) => {
|
|
|
|
|
await client.upload(fileName, fileContent);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async remove(fileName: string) {
|
|
|
|
|
const client = new FtpClient({
|
|
|
|
|
access: this.access,
|
|
|
|
|
logger: this.logger,
|
|
|
|
|
});
|
|
|
|
|
await client.connect(async (client) => {
|
|
|
|
|
await client.client.remove(fileName);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|