In general principle, this isn't possible. To view something, you have to download at least part of it.
However, you may be able to download the header of the archive (for particular formats) and read that. If it contains a list of filenames and sizes, that should give you enough information to "view the content" before downloading the entire file.
Most formats have a header segment with a known length (or recorded in the first few bytes of the file), so grabbing the first 8 bytes (4 for the type and 4 for the header length, let's say), then the rest of the header (based on the length) may be viable. It seems a bit awkward though.
In the case of a non-solid archive, you could also request a particular chunk corresponding to a file from the server, but I'm not sure how you'd go about decompressing it.
对于 ZIP 存档,这是不可能的,因为存储在存档中的有关文件的信息位于存档的末尾(中央目录)和每个压缩文件之前,即压缩文件数据第二个文件等。 因此,您只能查看存档中第一个文件的信息,要查看下载数据所需的所有进一步信息。
For ZIP archive this is not possible, since information about files, stored in archive is located at the end of archive (central directory) and before each compressed file, i.e. compressed file data second file and so on. So, you can only see information about first file in archive, and to see all further info you need to download data.
发布评论
评论(3)
编辑:根据评论,添加链接摘要页面中的建议。截至 2018 年 6 月,其中一项可能已过时。
这些 帮忙?他们提供了两种解决方案:
Edit: per comment, adding the suggestions from the linked summary page. One may be outdated as of 2018-06.
Would THESE help? They offer two solutions:
一般来说,这是不可能的。要查看某些内容,您必须至少下载其中的一部分。
但是,您可以下载存档的标题(针对特定格式)并阅读。如果它包含文件名和大小的列表,那么在下载整个文件之前,这应该为您提供足够的信息来“查看内容”。
大多数格式都有一个已知长度的标头段(或记录在文件的前几个字节中),因此获取前 8 个字节(4 个字节表示类型,4 个字节表示标头长度),然后是其余部分标头(基于长度)可能是可行的。不过似乎有点尴尬。
在非固体存档的情况下,您还可以从服务器请求与文件相对应的特定块,但我不确定您将如何解压缩它。
In general principle, this isn't possible. To view something, you have to download at least part of it.
However, you may be able to download the header of the archive (for particular formats) and read that. If it contains a list of filenames and sizes, that should give you enough information to "view the content" before downloading the entire file.
Most formats have a header segment with a known length (or recorded in the first few bytes of the file), so grabbing the first 8 bytes (4 for the type and 4 for the header length, let's say), then the rest of the header (based on the length) may be viable. It seems a bit awkward though.
In the case of a non-solid archive, you could also request a particular chunk corresponding to a file from the server, but I'm not sure how you'd go about decompressing it.
对于 ZIP 存档,这是不可能的,因为存储在存档中的有关文件的信息位于存档的末尾(中央目录)和每个压缩文件之前,即压缩文件数据第二个文件等。
因此,您只能查看存档中第一个文件的信息,要查看下载数据所需的所有进一步信息。
For ZIP archive this is not possible, since information about files, stored in archive is located at the end of archive (central directory) and before each compressed file, i.e. compressed file data second file and so on.
So, you can only see information about first file in archive, and to see all further info you need to download data.