I have org.apache.commons.compress.archivers.zip.ZipArchiveInputStream Object, from which I can get each ArchiveEntry item and get the individual file's metadata. But I need to know the way to get each file's contents as Blob.
我有org.apache.commons.compress.archivers.zip.ZipArchiveInputStream对象,我可以从中获取每个ArchiveEntry项并获取单个文件的元数据。但我需要知道将每个文件的内容作为Blob的方法。
Using org.apache.commons.compress.archivers.zip.ZipFile it can be done, but ZipFile has constructors with physical or temporary File object or a file location. I dont want to create a temporary File for this.
使用org.apache.commons.compress.archivers.zip.ZipFile可以完成,但ZipFile具有带有物理或临时File对象或文件位置的构造函数。我不想为此创建一个临时文件。
Even if there is a way to convert ZipArchiveInputStream to ZipFile, it would solve the problem indirectly.
即使有一种方法将ZipArchiveInputStream转换为ZipFile,它也会间接解决问题。
In short, my requirement is to read a Zip file from an InputStream/Blob and store individual Files as BLOB in Database.
简而言之,我的要求是从InputStream / Blob读取一个Zip文件,并将单个文件存储为数据库中的BLOB。
FYI: I am using org.apache.commons :: commons-compress :: 1.4.1
仅供参考:我使用的是org.apache.commons :: commons-compress :: 1.4.1
Any solutions/ideas/suggestions are highly appreciated.
任何解决方案/想法/建议都非常感谢。
Cheers Kum
1 个解决方案
#1
0
perhaps you could use standard java.util.zip.ZipInputStream - it has a constructor for InputStream. you can use getNextEntry()
/ closeEntry()
to iterate through entries and read()
to obtain decompressed data.
也许你可以使用标准的java.util.zip.ZipInputStream - 它有一个InputStream的构造函数。您可以使用getNextEntry()/ closeEntry()来遍历条目,使用read()来获取解压缩的数据。
#1
0
perhaps you could use standard java.util.zip.ZipInputStream - it has a constructor for InputStream. you can use getNextEntry()
/ closeEntry()
to iterate through entries and read()
to obtain decompressed data.
也许你可以使用标准的java.util.zip.ZipInputStream - 它有一个InputStream的构造函数。您可以使用getNextEntry()/ closeEntry()来遍历条目,使用read()来获取解压缩的数据。