-
-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DownloadDirectoryAsync not downloading relativly but always with full file name #852
Comments
This is highly dependent on your use case : I think the issue here is that FluentFTP does not know how to remove the prefix from the paths correctly. Can you suggest a more generic way that would work for all servers? |
A weird thing that I was able to observe was that for an Upload I was able to do everything with the out-of-the-box FluentFTP-APIs without running into any issues. I just passed the full remote path that contains the name of the ftpuser. I solved my problem by the following steps:
Other Devs can of course come up with a similar solution if needed, but maybe FluentFTP can provide some nice APIs for that. Suggestion 1:Currently
Solution 1:
Suggestion 2:Maybe a parameter |
Added to the bucket list. We will pick this up as and when we have free time. Comment on this issue if you want us to prioritize it. Thanks! |
FTP OS: Windows Server
FTP Server: Windows NT
Computer OS: Windows 11 Pro
FluentFTP Version: 37.0.2 on .NET 6
Problem
When using
DownloadDirectoryAsync
files are always downloaded with their full file names.The used FTP-Server got the username as root directory, in this example
/ftpuser
, not sure if that is anything usual.The remote file
/ftpuser/Remote_Folder/Sub_Folder/Sub_Folder_2/example.json
will be downloaded to the local fileC:\Local_Folder\ftpuser\Remote_Folder\Sub_Folder\Sub_Folder_2\example.json
.I expected the file to be downloaded to the local file
C:\Local_Folder\Sub_Folder_2\example.json
.Because i want the download to be relative, i tried changing the working directory, which did not change the behavior.
Because preceding did not work as I expected, I tried passing
var remoteFolder = "ftpuser/Remote_Folder/Sub_Folder"
to theDownloadDirectoryAsync
method, which ran into an exception.Problem Location
Reviewing the FluentFTP code for a solution, I found the method FtpClient_FolderDownload.cs - GetFilesToDownload on line 175 - code which calculates pathes on lines 182 and 183.
Possible Solutions
I reproduced the code on my machine and changed the mentioned lines as following:
Would be nice if the solution for the UserName will also be picked up, but I am not sure if that is an appropriate solution as i do not know if that is a usual or an unusual case.
Suggestions
To approache this problem, I thought it would be a nice idea to inherit FtpClient.
Sadly, a lot of useful code is private and not even protected, so i had to search the FluentFTP codebase a while to find everything i need and copy it to my inherited FtpClient.
Maybe some methods could be made public to make more options available.
For example:
List<FtpResult> GetFilesToDownload(bunch of parameters){...}
bool FilePassesRules(FtpResult result, List<FtpRule>? rule, more parameters){...}
bool IsBlank(IEnumerable? value)
List<FtpResult>
as parameter for a download.The text was updated successfully, but these errors were encountered: