Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-508

Provide an API that can read ZIP archives in two passes over a stream

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.20
    • None
    • Archivers
    • Android 9 and Android 10, on both emulator and real device .

    Description

      I'm trying to use ZipArchiveInputStream to iterate over the items of a zip file (which may or may not be a real file on the file-system, which is why I use a stream), optionally creating a stream from specific entries.

      One of the operations I need is to get the size of the files within.

      For some reason, it fails to do so. Not only that, but it throws an exception when I'm done with it:

      Error:org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException: Unsupported feature data descriptor used in entry ...
      

      I've attached here 3 files:sample project, the problematic zip file (remember that you need to put it in the correct path and grant storage permission), and a screenshot of the issue.

      Note that if I open the file using a third party PC app (such as 7-zip  ), it works fine, including showing the file size inside.

      Files:

      test.zip

      ZipTest.zip

      Here's the relevant code (kotlin) :

       

              thread {
                  try {
                      val file = File("/storage/emulated/0/test.zip")
                      ZipArchiveInputStream(FileInputStream(file)).use {
                          while (true) {
                              val entry = it.nextEntry ?: break
                              Log.d("AppLog", "entry:${entry.name} ${entry.size} ")
                          }
                      }
                      Log.d("AppLog", "got archive ")
                  } catch (e: Exception) {
                      Log.d("AppLog", "Error:$e")
                      e.printStackTrace()
                  }
              }
      

      Attachments

        1. ZipTest3.zip
          139 kB
          AD_LB
        2. ZipTest2.zip
          138 kB
          AD_LB
        3. ZipTest.zip
          138 kB
          AD_LB
        4. test.zip
          686 kB
          AD_LB
        5. apkParser.zip
          304 kB
          AD_LB
        6. 2020-04-01_18-28-19.mp4
          1.63 MB
          AD_LB
        7. 2020-03-31_20-53-36.png
          120 kB
          AD_LB

        Activity

          People

            Unassigned Unassigned
            AndroidDeveloperLB AD_LB
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: