Indy FTP TransferType

I am using IdFTP component (Indy 10) to download some files (zip and txt) from a remote location. I set TransferType to binary before getting each file.

IdFTP.TransferType := ftBinary;
IdFTP.Get(ASource, ADest, AOverwrite);

      

I would expect both text and binary files to be loaded using binary mode. However, it looks like the contents of the text files are messed up whereas the zip files are downloading correctly. If I set TransferType to ASCII for text files, it works as expected. How can I determine which TransferType to set for a given file? Is there a common denominator or automatic tuning?

+2


source to share


3 answers


I don't see how the binary flag can mess up the transferred files. Binary type means that the server transfers files without any processing as is.

The only thing the FTP server should use the ASCII flag for is to properly handle line endings in text files, usually (1) either Line feed only on Unix, or (2) Carriage return + Line feed on Windows. But nowadays most text editors work like any system.



Thus, it is safest to use only the ASCII flag for very well known text files, perhaps only the .txt files, and use the binary flag for all others.

+6


source


If in doubt, rule it out (!) - try transferring files from the server using FTP from the Windows command line and see if the text files have disappeared. The program will transmit binary code (BIN command) or text (ASCII command). If you are transferring files with this and they still behave differently with your expectation, then something is done at the server end *. If they come up well, then either you (or Indy) do something. :-)



* How are text files messed up? If you transfer unicode text files, you might be better off transferring them as BINary. I must admit, as @unknown (yahoo) said, in most cases you should probably stick with BIN mode.

+3


source


I guess it will also depend on how you view the text file, ANSI or WideChar as to whether the text is messed up or not.

0


source







All Articles