In this post I am going to talk about the available solutions to verify whether a file transferred successfully from a FTP client to a FTP server. This is one of the problems we are currently working on in our project and we are open to find a better solution. Here I am writing about the solutions we came across and its open for discussions.
Though we get “226 transfer completed” status after a file transfer completion, which only says it is successfully sent from FTP client but does not guarantee file has sent to the FTP server
FTP is handled by ports 20 and 21. From these 2 ports one is assigned for data transfer and the other is assigned for commands.
1. Using ‘SIZE’ command
Most of the FTP clients and servers support ‘SIZE’ command. SIZE command will help to get file size of a given file in the server. Since the commands are transferred in a different channel this command after a file transfer will not interfere the other data transfers. So after considering the discussions happened based on this topic in forums, this is the most convenient way to verify the file transfer completion from a FTP client to a FTP server.
2. XCRC command
XCRC command is a proprietary command and this command uses a CRC(Cyclic Redundancy Check) algorithm to calculate the hash value of the file. If the CRC value of the local file and the remote file matches, then it is considered both files are equal and so the file transfer is successful and complete.
But very few FTP servers such as SmartFTP supports this command and unable to use with most of the available FTP server implementations.
3. md5deep – checksum
This is another checksum calculation. Using md5deep calculate a checksum both in local file and remote file and compare the values using another messaging service.
These are the three solutions we have in mind and we are planning to go with the SIZE command at the moment to ensure the happy path.