SFTP Download Files Matching a Pattern
Question:
I am trying your component to check if I can integrate it well in an application I need to transfer and manage files using SFTP over SSH.
I’ve examined the samples and there’s one thing I’d like to do and cannot find it.
Is it possible to read remote folder content but limited only to those items matching a given pattern?
I mean, something like:
sftp.OpenDir(“./*.xml”);
so that the listing returned by ReadDir contains only entries matching the pattern.
I need this because I could have folders with several hundreds of files, but maybe only few of them are interesting for a specific process, and I would like avoiding getting all the file entries (useless network traffic I guess).
Much better would be filtering them at the server side. Does your component allow this?
Answer:
There is nothing in the SFTP protocol that would allow you to request a directory listing for only files matching a pattern. Therefore, it is not possible to limit the size of the directory listing transferred from the server to the client. To download files matching a pattern, you would iterate over the files in the directory and then download each by name, as shown in this example:
ASP: SFTP Download Files Matching a Pattern
C#: SFTP Download Files Matching a Pattern
Delphi: SFTP Download Files Matching a Pattern
Visual FoxPro: SFTP Download Files Matching a Pattern
Java: SFTP Download Files Matching a Pattern
Perl: SFTP Download Files Matching a Pattern
PHP: SFTP Download Files Matching a Pattern
Python: SFTP Download Files Matching a Pattern
Ruby: SFTP Download Files Matching a Pattern
VB.NET: SFTP Download Files Matching a Pattern
Visual Basic: SFTP Download Files Matching a Pattern
VBScript: SFTP Download Files Matching a Pattern