#494 backup ftp server

This commit is contained in:
Hamid Reza Mohammadi 2026-07-10 16:30:51 +03:30
parent 5fc1238069
commit 56d7f0f25c

View File

@ -336,6 +336,27 @@ namespace RMuseum.Services.Implementation
await ftpClient.UploadFile(localFilePath, remoteFilePath);
await ftpClient.Disconnect();
}
if (bool.Parse(Configuration.GetSection("BackupFTPServer")["UploadEnabled"]))
{
var ftpClient = new AsyncFtpClient
(
Configuration.GetSection("BackupFTPServer")["Host"],
Configuration.GetSection("BackupFTPServer")["Username"],
Configuration.GetSection("BackupFTPServer")["Password"]
);
ftpClient.ValidateCertificate += FtpClient_ValidateCertificate;
await ftpClient.AutoConnect();
ftpClient.Config.RetryAttempts = 3;
RServiceResult<string> imgPath = _imageFileService.GetImagePath(img.Result);
if (!string.IsNullOrEmpty(imgPath.ExceptionString))
return new RServiceResult<GanjoorCatViewModel>(null, imgPath.ExceptionString);
var localFilePath = imgPath.Result;
var remoteFilePath = $"{Configuration.GetSection("BackupFTPServer")["RootPath"]}/images/CategoryImages/{Path.GetFileName(localFilePath)}";
await ftpClient.UploadFile(localFilePath, remoteFilePath);
await ftpClient.Disconnect();
}
}
cat.BookName = bookName;
cat.RImageId = imageId;