Uncompressed size CRC-32 Version Flags Compression Mod Time File Name Len Mod Date Extra Field Len CRC-32 File Name (variable size) 0 1 2 3 4 5 6 7 8 9 A B C D E F 0_ 1_ 2_ 3_
Size Uncompressed size Version Flags Compression Mod Time File Name Len Mod Date Extra Field Len Crc-32 File Name (variable size) 0_ 1_ 2_ 3_ Vers Needed File Comm Len Disk # start Internal Atr External Attributes Offset of local header File Comment (variable size) 4_ 5_ 0 1 2 3 4 5 6 7 8 9 A B C D E F
Local File Header 2 File Data 2 Local File Header … File Data … End of Central Directory Central Directory Headers File 1 File 2 … Local File Header n File Data n File n
Local File Header 2 File Data 2 End of Central Directory Central Directory File 1 File 2 File object 1 File object 2 File Info File object 1 File Info File object 1 Memory representation of file data need to create local and central directory headers File 3 object File Info File Data Local File Header 3 File Data 3 File 3 object File Info End of Central Directory Central Directory File 1 File 2 File 3 Blob Zip Archive String Collection of File Objects
Zip Archive String File object 1 Collection of File Objects File Info File object 1 Local File Header 2 File Data 2 File object 2 File Info File object 1 File 1 File 2 Local File Header 3 File Data 3 File 3 object File Info End of Central Directory Central Directory File 1 File 3
file Zip Archive String Collection of File Objects End of Central Directory Central Directory File 1 File 3 Local File Header 1 File Data 1 File object 1 File Info File object 1 Local File Header 3 File Data 3 File 3 object File Info Three.txt One.txt Change One.txt to First.txt Signature Compressed Size Uncompressed size Crc-32 Version Flags Compression Mod Time File Name Len Mod Date Extra Field Len Crc-32 File Name (7 bytes) 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 _ 1 _ 2 _ Signature Compressed Size Uncompressed size Crc-32 Version Flags Compression Mod Time File Name Len Mod Date Extra Field Len Crc-32 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 _ 1 _ 2 _ Local Header File name len = 7 File name = One.txt File name len = 9 File name = First.txt File Name (9 bytes)
file Zip Archive String Collection of File Objects End of Central Directory Central Directory File 1 File 3 Local File Header 1 File Data 1 File object 1 File Info File object 1 Local File Header 3 File Data 3 File 3 object File Info Three.txt One.txt Change One.txt to First.txt Signature Compressed Size Uncompressed size Crc-32 Version Flags Compression Mod Time File Name Len Mod Date Extra Field Len Crc-32 File Name (7 bytes) 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 _ 1 _ 2 _ Signature Compressed Size Uncompressed size Crc-32 Version Flags Compression Mod Time File Name Len Mod Date Extra Field Len Crc-32 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 _ 1 _ 2 _ Local Header File name len = 7 File name = One.txt File name len = 9 File name = First.txt File Name (9 bytes)
File Objects Local File Header 1 File Data 1 File object 1 File Info File object 1 Local File Header 3 File Data 3 File 3 object File Info FileName Length First.txt Three.txt 9 Three.txt First.txt End of Central Directory Central Directory File 1 File 3 Three.txt
= new Zippex(zipArchive); System.debug(myZip.getFileNames()); //{'file1.txt', 'file2.txt'} End of Central Dir Central Dir File 1 File 2 Local File Header 1 File Data 1 Local File Header 2 File Data 2 file1.txt file2.txt zipArchive
Zippex myZip = new Zippex(zipArchive); System.debug(myZip.getFileNames()); //{'file1.txt', 'file2.txt'} Blob data = myZip.getFile('file2.txt'); End of Central Dir Central Dir File 1 File 2 Local File Header 1 File Data 1 Local File Header 2 File Data 2 file1.txt file2.txt zipArchive
wordBlob = [SELECT Body FROM Attachment WHERE Name = 'TestData.docx' LIMIT 1].Body; Zippex sampleZip = new Zippex(wordBlob); for (String fileName : sampleZip.getFileNames()) System.debug(fileName);