Is it possible to download just part of a ZIP archive (e.g. one file)?

前端 未结 7 613
时光说笑
时光说笑 2020-12-14 17:51

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 a

相关标签:
7条回答
  • 2020-12-14 18:50

    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.

    0 讨论(0)
提交回复
热议问题