Method SFTPClient():getFile() Foundation

Downloads a file.

Syntax
:getFile( <cRemoteFile>, [<cLocalFile>], [<bProgressBlock>] ) --> lSuccess
Parameters
<cRemoteFile>
The relative or fully qualified path of the remote file to download.
<cLocalFile>
The relative or fully qualified path of the local file. The parameter is optional. If no path is given, the local path defaults to the filename provided in the parameter <cSourceFileName>. If a file with the same path already exists, it is overwritten. Otherwise, a new file is created.
<bProgressBlock>
An optional code block which is evaluated while the file is downloaded from the FTP server. The code block can be used for monitoring or visualizing the progress of the file transfer. The code block is evaluated with the following parameters:
{|nRead, nTotal| ... } 
The first parameter <nRead> is the number of bytes already transferred from the server. The second parameter <nTotal> indicates the total number of bytes to download.
Return

.T. (true) if the download is successful, .F. (false) otherwise.

Description

Downloads a remote file from the SFTP server and writes the content to a local file.

Unlike :get(), the data is read from the server and written to the file holding only one data chunk in memory at a time, thus optimizing memory footprint.

If the remote file does not exist, the operation fails. If a local file with the same name already exists, it is overwritten.

In case of an error condition, use :getLastError() and :getLastMessage() methods to obtain detailed error information.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.