Hi all,
We need to download files in a listed directory. I have a couple of questions regarding the callback event OnDirectoryList of TScSFTPClient as well as the TScSFTPClient.DownloadFile, UploadFile methods
1) Is it a good practice to download every single file by calling the SFTPClient.DownloadFile in the callback OnDirectoryList or we should save all files into a list first. Then iterate through the file list and call the DownloadFile?
2) The FileInfo: TScSFTPFileInfo returned from the callback, is it always assigned? Am I correct to do the following to check whether the returned FileInfo it is a file:
[code] if not Assigned(FileInfo) or (FileInfo.Attributes.FileType <> ftFile) then begin
Exit;
end;[/code]
3) With the DownloadFile(Source) and UploadFile(Destination), which operating system path types should I pass in DOS(\Server\Doc\file.txt or UNIX(/Server/Doc/file.txt)? Or Does the components support both DOS and Unix path separators?
Thank you,
Tran
DownloadFile, UploadFile and OnDirectoryList
Re: DownloadFile, UploadFile and OnDirectoryList
1. To solve the defined task, it's more convenient to save file names to a list and then download the files using the list.
2. Yes, your code is correct and should solve the defined task.
3. Most SFTP servers use the Unix format, however, there may be exceptions.
2. Yes, your code is correct and should solve the defined task.
3. Most SFTP servers use the Unix format, however, there may be exceptions.
-
- Posts: 3
- Joined: Thu 14 Nov 2019 04:33
Re: DownloadFile, UploadFile and OnDirectoryList
Hi ViktorV,
Thanks for your response.
I just need a bit more details for question 3. What do you recommend for the path? When the request hit the server, does the SFTPClient component automatically handle the conversions for path separators from DOS to UNIX or vice-versa? Or should I specify the path type according to the server's specification, eg: if the server path is in UNIX then I should use UNIX.
Regards,
Tran
Thanks for your response.
I just need a bit more details for question 3. What do you recommend for the path? When the request hit the server, does the SFTPClient component automatically handle the conversions for path separators from DOS to UNIX or vice-versa? Or should I specify the path type according to the server's specification, eg: if the server path is in UNIX then I should use UNIX.
Regards,
Tran
-
- Posts: 132
- Joined: Wed 17 Aug 2016 05:57
Re: DownloadFile, UploadFile and OnDirectoryList
Always use forward slashes and you will be fine.
Windows does not care if the slashes are / or \
i.e. this would work just fine on windows:
c:\myfolder\12/20/2019
I have used such paths with the force directories function and it creates the path just fine even with the different slashes.
Windows does not care if the slashes are / or \
i.e. this would work just fine on windows:
c:\myfolder\12/20/2019
I have used such paths with the force directories function and it creates the path just fine even with the different slashes.
-
- Posts: 3
- Joined: Thu 14 Nov 2019 04:33
Re: DownloadFile, UploadFile and OnDirectoryList
Thanks for your reply tcaduto12068. I will just force the UNIX path.
Cheers
Cheers
Re: DownloadFile, UploadFile and OnDirectoryList
As tcaduto12068 said, Windows does not care if the slashes are / or \, so you can try using the Unix format.