Zip文件错误“标头已损坏”当我使用java ZipEntry类将exta字段添加到标题中时 [英] Zip File error "header is corrupt" when i am adding exta field into header using java ZipEntry Class
问题描述
我在压缩时在标题的额外字段中设置了 Content Type = text / xml
。
PK * H27664.040.678.FI00091710.xmlContentType = text / xml
$ b
删除额外字段 Content Type = text / xml
一切正常。
我需要设置页眉额外字段,因为它对我来说是必要的。有人可以帮助我如何在不增加额外字段的情况下继续操作。
请帮助。
在此先感谢
额外字段本身具有您必须遵守的内部格式。从 PKWare应用笔记:
4.5.1为了允许不同程序和不同类型的
信息存储在.ZIP
文件的'extra'字段中,以下结构必须用于存储数据的所有
程序:
header1 + data1 + header2 + data2。 。 。
每个标题应包含:
标题ID - 2个字节
数据大小 - 2个字节
注意:存储在英特尔低字节/高字节顺序。
标题ID字段表示
后面的数据块中的数据类型。
0到31的标题ID保留供PKWARE使用。
其他ID可由第三方供应商用于
专有使用。
4.5.2当前由PKWARE定义的Header ID映射如下:
0x0001 Zip64扩展信息额外字段
0x0007 AV信息
0x0008保留用于扩展语言编码数据(PFS)
(见附录D)
0x0009 OS / 2
0x000a NTFS
0x000c OpenVMS
0x000d UNIX
0x000e为文件流保留和分支描述符
0x000f补丁描述符
0x0014 PKCS#7 X.509证书的存储
0x0015 X.509证书ID和签名用于
单个文件
0x0016 X. 509中央目录的证书ID
0x0017强加密标题
0x0018记录管理控制
0x0019 PKCS#7加密收件人证书列表
0x0065 IBM S / 390(Z390),AS / 400 (I400)attr ibutes
- 未压缩
0x0066为IBM S / 390(Z390),AS / 400(I400)保留
属性 - 压缩
0x4690 POSZIP 4690(保留)
所以你需要编写一个标题ID,并在文本前面使用它和数据大小。 b $ b
I set Content Type=text/xml
in extra field of header while compressing. Below is my header.
PK�*�H27664.040.678.FI00091710.xmlContent Type=text/xml
It gives me error while decompressing validation fails "Header is corrupt".
When removing the extra field Content Type=text/xml
everything works fine.
I need to set header extra field as it s necessary for me. Can someone help me how I can proceed it without getting error with extra field.
Please help. Thanks in advance
The extra field itself has an internal format that you are required to adhere to. From the PKWare appnote:
4.5.1 In order to allow different programs and different types
of information to be stored in the 'extra' field in .ZIP
files, the following structure MUST be used for all
programs storing data in this field:
header1+data1 + header2+data2 . . .
Each header should consist of:
Header ID - 2 bytes
Data Size - 2 bytes
Note: all fields stored in Intel low-byte/high-byte order.
The Header ID field indicates the type of data that is in
the following data block.
Header IDs of 0 thru 31 are reserved for use by PKWARE.
The remaining IDs can be used by third party vendors for
proprietary usage.
4.5.2 The current Header ID mappings defined by PKWARE are:
0x0001 Zip64 extended information extra field
0x0007 AV Info
0x0008 Reserved for extended language encoding data (PFS)
(see APPENDIX D)
0x0009 OS/2
0x000a NTFS
0x000c OpenVMS
0x000d UNIX
0x000e Reserved for file stream and fork descriptors
0x000f Patch Descriptor
0x0014 PKCS#7 Store for X.509 Certificates
0x0015 X.509 Certificate ID and Signature for
individual file
0x0016 X.509 Certificate ID for Central Directory
0x0017 Strong Encryption Header
0x0018 Record Management Controls
0x0019 PKCS#7 Encryption Recipient Certificate List
0x0065 IBM S/390 (Z390), AS/400 (I400) attributes
- uncompressed
0x0066 Reserved for IBM S/390 (Z390), AS/400 (I400)
attributes - compressed
0x4690 POSZIP 4690 (reserved)
So you need to make up a header ID, and use that and a data size preceding your text.
这篇关于Zip文件错误“标头已损坏”当我使用java ZipEntry类将exta字段添加到标题中时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!