我从 FTP 服务器(URL:ftp://foo.com/bar/...) 这对我来说很陌生。您能给我提供一些文档或解释一下以下内容是如何实现的吗?
如果我使用 wget 获取文件夹的 URL,我会得到一个index.html
(显示在帖子底部)以下列表,表明只有压缩文件可用:os_image_123_0-incr-repo.iso.gz
我可以通过 wget 获取此文件的 URL,然后我将得到一个带有特定 MD5 校验和的 gzip 文件。
c4fd702b3ad296561b2ec7e4b888e624 os_image_123_0-incr-repo.iso.gz
os_image_123_0-incr-repo.iso.gz: gzip compressed data - deflate method , original file name
但是我也可以通过 wget 获取相同的文件 URL,省略.gz
扩展名,只留下文件名os_image_123_0-incr-repo.iso
,现在我将得到一个 iso 文件,该文件未在index.html
.
08daf88aca95325c3aa9ae6406e02198 os_image_123_0-incr-repo.iso
os_image_123_0-incr-repo.iso: ISO 9660 filesystem image
就好像 wget“知道”从 iso.gz 文件中提取 iso。
这是怎么回事?它是如何运作的?
index.html
这是文件夹中列出的内容:
2016 Apr 13 14:45 Directory <a href="ftp://foo.com/bar/05/.RE/">.RE/</a>
2016 Apr 13 14:36 File <a href="ftp://foo.com/bar/05/README.11.3.7">README.11.3.7</a> (3097 bytes)
2016 Apr 13 14:36 File <a href="ftp://foo.com/bar/05/md5sum-repo-iso-123_0.txt">md5sum-repo-iso-123_0.txt</a> (63 bytes)
2016 Apr 13 13:02 File <a href="ftp://foo.com/bar/05/md5sums.txt">md5sums.txt</a> (321 bytes)
2016 Apr 13 09:52 File <a href="ftp://foo.com/bar/05/os_image_123_0-ai-sparc.iso">os_image_123_0-ai-sparc.iso</a> (570142720 bytes)
2016 Apr 13 09:53 File <a href="ftp://foo.com/bar/05/os_image_123_0-ai-x86.iso">os_image_123_0-ai-x86.iso</a> (496521216 bytes)
2016 Apr 13 13:02 File <a href="ftp://foo.com/bar/05/os_image_123_0-fallback_boot-sparc.pkg">os_image_123_0-fallback_boot-sparc.pkg</a> (103859114 bytes)
2016 Apr 13 14:37 File <a href="ftp://foo.com/bar/05/os_image_123_0-incr-repo.iso.gz">os_image_123_0-incr-repo.iso.gz</a> (3613854717 bytes)
2016 Apr 13 09:52 File <a href="ftp://foo.com/bar/05/os_image_123_0-text-sparc.iso">os_image_123_0-text-sparc.iso</a> (885370880 bytes)
2016 Apr 13 09:53 File <a href="ftp://foo.com/bar/05/os_image_123_0-text-x86.iso">os_image_123_0-text-x86.iso</a> (795648000 bytes)
2016 Apr 13 14:38 Directory <a href="ftp://foo.com/bar/05/zipped-repo/">zipped-repo/</a>
添加 wget 输出。
[my_user 503 0 /tmp]$ wget ftp://foo.bar.com/products/Solaris_11/s11.3/support/sru07/05/sol-11_3_7_5_0-incr-repo.iso.gz
--2016-05-10 06:39:19-- ftp://foo.bar.com/products/Solaris_11/s11.3/support/sru07/05/sol-11_3_7_5_0-incr-repo.iso.gz
=> ‘sol-11_3_7_5_0-incr-repo.iso.gz’
Resolving foo.bar.com (foo.bar.com)... 10.10.11.11
Connecting to foo.bar.com (foo.bar.com)|10.10.11.11|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /products/Solaris_11/s11.3/support/sru07/05 ... done.
==> SIZE sol-11_3_7_5_0-incr-repo.iso.gz ... 3613854717
==> PASV ... done. ==> RETR sol-11_3_7_5_0-incr-repo.iso.gz ... done.
Length: 3613854717 (3.4G) (unauthoritative)
sol-11_3_7_5_0-incr-repo.iso.gz 100%[===========================================================================>] 3.37G 99.5MB/
2016-05-10 06:39:56 (94.4 MB/s) - ‘sol-11_3_7_5_0-incr-repo.iso.gz’ saved [3613854717]
[my_user 505 0 /tmp]$ wget ftp://foo.bar.com/products/Solaris_11/s11.3/support/sru07/05/sol-11_3_7_5_0-incr-repo.iso
--2016-05-10 06:43:25-- ftp://foo.bar.com/products/Solaris_11/s11.3/support/sru07/05/sol-11_3_7_5_0-incr-repo.iso
=> ‘sol-11_3_7_5_0-incr-repo.iso’
Resolving foo.bar.com (foo.bar.com)... 10.10.11.11
Connecting to foo.bar.com (foo.bar.com)|10.10.11.11|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /products/Solaris_11/s11.3/support/sru07/05 ... done.
==> SIZE sol-11_3_7_5_0-incr-repo.iso ... done.
==> PASV ... done. ==> RETR sol-11_3_7_5_0-incr-repo.iso ... done.
sol-11_3_7_5_0-incr-repo.iso [ <=> ] 4.04G 32.3MB/
2016-05-10 06:45:39 (30.9 MB/s) - ‘sol-11_3_7_5_0-incr-repo.iso’ saved [4337887232]
答案1
很可能服务器被配置为查找.gz
文件,当未找到请求的文件时,返回提取的内容。
mod_rewrite
使用 HTTP,使用 Apache和模块进行设置可能很容易mod_deflate
。不确定某些 FTP 服务器是否支持此功能。