-
-
Notifications
You must be signed in to change notification settings - Fork 656
FXP Server To Server
Tip: For detailed documentation refer to the IntelliSense tips that appear when you call a given API method.
-
TransferFile() - Transfer the specified file from the source FTP Server to the destination FTP Server using the FXP protocol. Returns
FtpStatus
to indicate success, skipped or failed. Exceptions are thrown for critical errors. Supports very large files since it uploads data in chunks. Optionally verifies the hash of a file & retries transfer if hash mismatches. Provides detailed progress tracking and metrics via callbacks by sending anFtpProgress
object. -
TransferDirectory() - Transfers the specified directory from the source FTP Server onto the remote FTP Server using the FXP protocol. You will need to create a valid connection to your remote FTP Server before calling this method. If any rules are provided then we only upload the files and folders matching all the rules. Returns one
FtpResult
per file or folder, containing its detailed transfer status. All exceptions during uploading are caught, and the exception is stored in the relatedFtpResult
and uploading continues. Optionally verifies the hash of the files & retries transfer if hash mismatches. Provides detailed progress tracking and metrics via callbacks by sending anFtpProgress
object.
-
All the file transfer settings are also applicable for FXP transfers.
-
Config.FXPDataType - Controls if the FXP methods use Binary or ASCII mode. Default: Binary.
-
Config.FXPProgressInterval - Controls how often the progress reports are sent during an FXP file transfer. Default: 1000 (1 second).
FXP is useful to reduce the overheads of data transfer by allowing you to transfer data directly from one server to another, bypassing the usual download/upload cycle. FXP works by creating a data connection between two FTP servers. FluentFTP can then instruct the source server to start transferring the file and instruct the target server to receive and store it.
You need to call the API in this order:
- You need to create an
FtpClient
instance and connect to the source server - You need to create an
FtpClient
instance and connect to the target server - Call
source.TransferFile
orsource.TransferDirectory
on the source FTP client and provide the target server's FtpClient to make an FXP connection between them
The order of FTP commands is as follows:
- We connect to the source server
- We clone the connection of the target server (and reconnect to it)
- Internally, we open a passive FXP connection between the source server and target server
- We maintain an
FtpFxpSession
object used to track the active FXP connection between 2 servers - We instruct the source server to send the file, using the
RETR
FTP command - We instruct the target server to store the file, using the
STOR
FTP command - If the transfer is interrupted or disconnected midway, we resume transfer by instructing the source server to resume using
REST
andRETR
FTP command and the target server to store append the file usingAPPE
FTP command - We can only check the file transfer progress by constantly sending the
SIZE
command on the target server to check how many bytes have transferred - At the end of transferring the file we optionally verify the file using any mutually supported hash method and then call
GetChecksum()
on the source and target server and check if the hash matches - Finally, we disconnect from the target server and the
FtpFxpSession
is disposed off
See this Folder Transfer FAQ to learn about the FtpResult
objects returned by TransferDirectory
.
See the Rules page for info and code examples.
See this File Transfer FAQ for basic information on progress tracking. In addition to the basic properties you can access these properties in the FtpProgress
object to find out which file is being transferred:
-
LocalPath - Stores the absolute path of the current file on the source FTP server.
-
RemotePath - Stores the absolute path of the current file on the target FTP server.
-
FileIndex - Stores the 0-based index of the the file in the list.
-
FileCount - Stores the total count of the files to be transferred. This does not include directories.
- Auto Connection
- Auto Reconnection
- FTP(S) Connection
- FTP(S) Connection using GnuTLS
- FTPS Proxies
- Custom Servers
- Custom Commands
- v40 Migration Guide