Skip to content

Commit 2f4fd64

Browse files
committed
Fixing the issue when conecting to the FTP using the port 21 over SSL
1 parent 290b5aa commit 2f4fd64

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

DataImport.Server.TransformLoad/Features/FileTransport/FileServer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public async Task<IEnumerable<string>> GetFileList(Agent ftpsAgent)
4949
{
5050
client.ValidateCertificate += OnValidateFtpsCertificate;
5151
await client.ConnectAsync();
52+
if (String.IsNullOrEmpty(ftpsAgent.FilePattern))
53+
list.AddRange(from file in await client.GetListingAsync(ftpsAgent.Directory)
54+
where file.Type == FtpFileSystemObjectType.File
55+
select file.FullName);
5256

5357
list.AddRange(from file in await client.GetListingAsync(ftpsAgent.Directory)
5458
where file.Type == FtpFileSystemObjectType.File && file.Name.IsLike(ftpsAgent.FilePattern)
@@ -122,6 +126,9 @@ public async Task<IEnumerable<string>> GetFileList(Agent sftpAgent)
122126
_logger.LogInformation("Connected, server version: {version}", client.ConnectionInfo.ServerVersion);
123127

124128
var fileList = client.ListDirectory(sftpAgent.Directory);
129+
if (String.IsNullOrEmpty(sftpAgent.FilePattern))
130+
list.AddRange(from file in fileList select file.FullName);
131+
125132
list.AddRange(from file in fileList
126133
where file.Name.IsLike(sftpAgent.FilePattern)
127134
select file.FullName);

DataImport.Web/Features/Agent/AgentFiles.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ private static IEnumerable<string> GetAgentFiles(string url, int? port, string u
8686

8787
using (var ftpsClient = new FtpClient(url, port.Value, username, password))
8888
{
89-
ftpsClient.EncryptionMode = FtpEncryptionMode.Implicit;
89+
ftpsClient.EncryptionMode = FtpEncryptionMode.Explicit;
9090
ftpsClient.ValidateCertificate += OnValidateFtpsCertificate;
9191
ftpsClient.Connect();
9292
if (!ftpsClient.IsConnected) throw new Exception("Ftps Client Cannot Connect");
93+
if (String.IsNullOrEmpty(filePattern))
94+
return ftpsClient.GetListing(directory).Where(x =>
95+
x.Type == FtpFileSystemObjectType.File).Select(x => x.Name).ToList();
96+
9397
return ftpsClient.GetListing(directory).Where(x =>
9498
x.Type == FtpFileSystemObjectType.File && x.Name.IsLike(filePattern.Trim())).Select(x => x.Name).ToList();
9599
}
@@ -105,8 +109,10 @@ private static IEnumerable<string> GetAgentFiles(string url, int? port, string u
105109
sftpClient.Connect();
106110
if (!sftpClient.IsConnected) throw new Exception("Sftp Client Cannot Connect");
107111
filePattern = filePattern.Trim();
112+
if (String.IsNullOrEmpty(filePattern))
113+
return sftpClient.ListDirectory(directory).Select(x => x.Name).ToList();
108114
return sftpClient.ListDirectory(directory).Where(x => x.Name.IsLike(filePattern))
109-
.Select(x => x.Name).ToList();
115+
.Select(x => x.Name).ToList();
110116
}
111117
}
112118
}

0 commit comments

Comments
 (0)