Internet Direct (Indy)
Home
PreviousUpNext
TIdFTP.Get Method (string, TIdStream, Boolean)

Retrieves a file using the FTP protocol.

Pascal
procedure Get(
    const ASourceFile: string; 
    ADest: TIdStream; 
    AResume: Boolean = false
); overload;
Parameters 
Description 
ASourceFile 
File name on the FTP server.
 
ADest 
Stream where file data will be written.
 
AResume 
Partial download can be completed. 

Get is an overloaded procedure that allows the FTP client to retrieve a file with the name specified in ASourceFile from the FTP server using the FTP RETR command. 

Values retrieved from the server are stored locally in the stream specified in ADest. 

Get allows continuing a previous partial download or appending data to an existing file on the local file system when AResume is True and CanResume indicates that the FTP server implementation allows the FTP REST command verb. 

Internal processing for the Get method will also trigger the OnStatus event handler with the ftpTransfer status value, reads data from the FTP server, and signals the the OnStatus event handler with the ftpReady status value on completion. OnStatus may be triggered with the value ftpAborted if the response code from the FTP server is the numeric values 225 or 226. 

During data retrieval, Get calls methods that initialize the DataChannel for the FTP client using the connection type specificed in Passive

When Passive contains True, the FTP PASV or EPSV commands are used to configure the IP address and Port number for the data channel. When Passive contains False, the FTP PORT or EPRT commands are used to configure the IP address and Port number for the data channel using the value indicated in DataPort, DataPortMin, and DataPortMax. UsingExtDataPort indicates if the FTP EPORT command is required. 

The OnDataChannelCreate event handler is signaled prior to opening the data channel connection. 

When both AResume and CanResume contain True, the FTP REST command is sent using the existing length of aDestFile as the initial position for the resumed data transfer. 

A secure socket transport for the data channel is updated based on values in DataPortProtection and UsingSFTP prior to tranmission of data. 

The current value in TransferMode is used to determine if ZLib compression has been applied to data during transmission. When TransferMode contains dmDeflate, the Compressor object instance is used to read compressed data on the data channel socket transport. When TransferMode contains dmStream, data is read from the transport using the IPOHandler for the data channel. 

After completion of the retrieval process, Get signals the OnDataChannelDestroy event handler and frees the data channel for the FTP client. 

Get also signals the OnAfterGet event handler following completion of the data transfer. 

Use Put to transfer data from the FTP client to the FTP server.

Discuss enabling LargeStream support in IOHandlers using OnDataChannelCreate

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.