Is it possible to download just part of a ZIP arch

2020-02-09 01:42发布

I was wondering is there any way by which I can download only a part of a .rar or .zip file without downloading the whole file ? 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 ?

标签: zip rar
7条回答
Fickle 薄情
2楼-- · 2020-02-09 02:05

There are several ways for a normal person to be able to download an individual file from a compressed ZIP file, unfortunately they aren't common knowledge. There are some open-source tools and online web services, including:

查看更多
别忘想泡老子
3楼-- · 2020-02-09 02:07

You can use FDM, it's support Zip files partial download: Free Download Manager lets you download only the necessary part of a zip file.

http://www.freedownloadmanager.org/features.htm

查看更多
ゆ 、 Hurt°
4楼-- · 2020-02-09 02:07

Instead, use Google Docs's reader. Goto this link- https://docs.google.com/viewer?url=http://file.zip and change the address of zip file. It can open both zip and rar files

查看更多
兄弟一词,经得起流年.
5楼-- · 2020-02-09 02:10

Can you arrange for your file to appear in the back of the zip?

Download 100k:

$ curl -r -100000 https://www.keepassx.org/releases/2.0.2/KeePassX-2.0.2.zip -o tail.zip
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
100   97k  100   97k    0     0  84739      0  0:00:01  0:00:01 --:--:-- 84817

Check what files we did get:

$ unzip -t tail.zip
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
error [tail.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
error [tail.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
error [tail.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
error [tail.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
    testing: KeePassX-2.0.2/share/translations/keepassx_uk.qm   OK
    testing: KeePassX-2.0.2/share/translations/keepassx_zh_CN.qm   OK
    testing: KeePassX-2.0.2/share/translations/keepassx_zh_TW.qm   OK
    testing: KeePassX-2.0.2/zlib1.dll   OK
At least one error was detected in tail.zip.

Then extract the last file:

$ unzip tail.zip KeePassX-2.0.2/zlib1.dll
Archive:  tail.zip
error [tail.zip]:  missing 7751495 bytes in zipfile
  (attempting to process anyway)
  inflating: KeePassX-2.0.2/zlib1.dll  
查看更多
Rolldiameter
6楼-- · 2020-02-09 02:13

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 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 that you want get transferred over the network.

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

Get/build 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 

Mount a remote zip file and extract one file from it:

$ 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 

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)

I'm aware that this is an old question, this is for others running into this problem.

查看更多
祖国的老花朵
7楼-- · 2020-02-09 02:15

I think Sergei Tulentsevs idea is brilliant.

However, if there is control over the server -- e.g. custom code can be deployed -- then it is a rather trivial operation (in the scheme of things :) to map/handle a request, extract the relevant portion of the ZIP archive, and send the data back in the HTTP stream.

The request might look like:

http://foo.bar/myfile.zip_a.jpeg

Which would mean extract -- and return -- "a.jpeg" from "myfile.zip".

(I intentionally chose this silly format so that browsers would likely choose "myfile.zip_a.jpeg" as the name in the download dialog when it appears.)

Of course, how this is implemented depends on the server/language/framework and there may already be existing solutions that support a similar operation (but I know not).

Happy coding.

查看更多
登录 后发表回答