Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

zip

rar

Is there a 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?

like image 228
user1026134 Avatar asked Dec 17 '11 06:12

user1026134


People also ask

How do I extract only part of a ZIP file?

Right-click on any of the zip files that are a part of the collection and click on the "Extract here" or "Extract to folder" option in the pop-up menu. Your zip application will load up and begin decompressing all the files. A progression bar will appear on the screen and once it is fully loaded, it will fade away.

How do I extract an incomplete ZIP file?

To extract, or open, a ZIP file, use an unZIP utility, or an extractor, such as WinZIP or 7ZIP, a free utility from 7ZIP.org. The unZIP utility will open incomplete files, but consult an IT professional for help. The process requires using the command line utility, which is an open door to the operating system.

How can I view a ZIP file without extracting it?

zip lists the contents of a ZIP archive to ensure your file is inside. Use the -p option to write the contents of named files to stdout (screen) without having to uncompress the entire archive.

Where do Zip files go after download?

Zip files are usually downloaded to a location that is specific to your operating system. For Windows-based computers, zip files are typically saved in the My Documents or Downloads folder unless you've specified something else as the default download destination for your computer.


3 Answers

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.

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).

like image 178
Adam Avatar answered Sep 20 '22 09:09

Adam


In a way, yes, you can.

ZIP file format says that there's a "central directory". Basically, this is a table that stores what files are in the archive and what offsets do they have.

So, using Content-Range you could download part of the file from the end (the central directory is the last thing in a ZIP file) and try to identify the central directory in it. If you succeed then you know the file list and offsets, so you can proceed and get those chunks separately and decompress them yourself.

This approach is quite error-prone and is not guaranteed to work. But so is hacking in general :-)

Another possible approach would be to build a custom server for that (see pst's answer for more details).

like image 36
Sergio Tulentsev Avatar answered Sep 22 '22 09:09

Sergio Tulentsev


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:

  • Windows: Iczelion's HTTP Zip Dowloader (open-source) (that I've used for over 10 years!)
  • Linux: partial-zip (open-source)
  • Online: wobzip.org (closed-source)
like image 28
Shervin Emami Avatar answered Sep 19 '22 09:09

Shervin Emami