ftp 服务器文件大小与实际文件大小的差异

Mah*_*der 4 ftp protocol

我正在连接到 FTP 服务器以下载一些 gzipped 文件,我注意到 SIZE 命令有点令人不安,我的 google-fu 失败了。

ftp> size file0001.xml.gz
213 2524751

ftp> nlist -ltr
...
-rw-r--r--   1 anon  anons    2515727 Jan 30 00:00 file0001.xml.gz
...
Run Code Online (Sandbox Code Playgroud)

如您所见,文件大小不同 (2524751 != 2515727)。为什么?

我简要阅读了RCF0959 文件传输协议 (FTP),但没有提到 SIZE 命令,后来我发现它是协议的非标准补充。

为方便起见,以下是 RFC 中有关字节大小的信息:

  byte size

     There are two byte sizes of interest in FTP:  the logical byte
     size of the file, and the transfer byte size used for the
     transmission of the data.  The transfer byte size is always 8
     bits.  The transfer byte size is not necessarily the byte size
     in which data is to be stored in a system, nor the logical byte
     size for interpretation of the structure of the data.
Run Code Online (Sandbox Code Playgroud)

我在这里缺少什么?

谢谢!

马哈茂德

Dou*_*der 8

您是否已将 ftp 切换到binary模式?ftp 可能正在计算改变行尾的大小?

2524751 / 2515727 * 255 = 255.91469384396638

所以看起来原始文件中每 255 个字节多增加 0.9 个字节 - 刚好足以将压缩文件\n转换为\r\n.