是否可以只下载 ZIP 存档的一部分(例如一个文件)? [英] Is it possible to download just part of a ZIP archive (e.g. one file)?

查看:18
本文介绍了是否可以只下载 ZIP 存档的一部分(例如一个文件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法只下载 .rar 或 .zip 文件的一部分而不下载整个文件?

Is there a way by which I can download only a part of a .rar or .zip file without downloading the whole file?

有一个包含文件 A、B、C 和 D 的 ZIP 文件.我只需要 A.我可以以某种方式调整下载以仅下载 A,或者如果可能的话在服务器本身中提取文件并仅获得 A?

There is a ZIP file containing files A, B, C, and D. I only need A. Can I somehow tweak the download to download only A or if possible extract the file in the server itself and get A only?

推荐答案

诀窍在于Sergio 建议 无需手动操作.如果您通过 HTTP 支持的虚拟文件系统挂载 ZIP 文件,然后在其上使用标准的 unzip 命令,这很容易.通过这种方式,解压缩实用程序的 I/O 调用被转换为 HTTP 范围 GET,这意味着只有您希望通过网络传输的 ZIP 文件块.

The trick is to do what Sergio suggests without doing it manually. This is easy if you mount the ZIP file via an HTTP-backed virtual filesystem and then use the standard unzip command on it. This way the unzip utility's I/O calls are translated to HTTP range GETs, which means only the chunks of the ZIP file that you want get transferred over the network.

这是一个使用 HTTPFS 的 Linux 示例,这是一个非常轻量级的虚拟文件系统(它使用 FUSE).有适用于 Windows 的类似工具.

Here's an example for Linux using HTTPFS, a very lightweight virtual filesystem (it uses FUSE). There are similar tools for Windows.

获取/构建 httpfs:

$ wget http://sourceforge.net/projects/httpfs/files/httpfs/1.06.07.02
$ tar -xjf httpfs_1.06.07.10.tar.bz2
$ rm httpfs
$ ./make_httpfs

安装远程 ZIP 文件并从中提取一个文件:

$ mkdir mount_pt
$ sudo ./httpfs http://server.com/zipfile.zip mount_pt
$ sudo ls mount_pt
zipfile.zip
$ sudo unzip -p mount_pt/zipfile.zip the_file_I_want.txt > the_file_I_want.txt
$ sudo umount mount_pt

当然,除了命令行之外,您还可以使用任何其他工具(我需要 sudo 因为在我的机器上似乎 FUSE 是这样设置的,你不应该需要它).

Of course you can also use whatever other tools beside the command-line one (I need sudo because it seems FUSE is set up that way on my machine, you shouldn't have to need it).

这篇关于是否可以只下载 ZIP 存档的一部分(例如一个文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆