omicronapps / 7-Zip-JBinding-4Android

Android Java wrapper for 7z archiver engine
GNU Lesser General Public License v2.1
121 stars 24 forks source link

Unable to compress file types other than txt #21

Closed asthagarg2428 closed 2 years ago

asthagarg2428 commented 2 years ago

I tried compression with 1 docx and other mp4 files and on extracting the same compressed files, the obtained files can't be viewed.

Steps:-

  1. I changed the create method of CompressArchiveStructure.java to return me the Items containing files from assets folder of type docx and mp4.

    public static Item[] create(Context context) {
    
        Item[] items = new Item[2];
        try {
            String file1 = Helper.getDocFileFromAsset(context).getPath();
            items[0] = new Item(file1, Helper.getStringFromFile(file1));
            String file2 = Helper.getMP4FileFromAsset(context).getPath();
            items[1] = new Item(file2, Helper.getStringFromFile(file2));
    
        } catch (Exception e) {
            e.printStackTrace();
        }
        return items;
    }
  2. Calling compress with ZIP format from MainActivity

    CompressGeneric().compress(
            "${Environment.getExternalStorageDirectory()}/Download/demo/compressed_zip.zip",
            "ZIP", 2, this
        )
  3. Run the App, You will see thet the compressed_zip.zip is generated at the right path and extract the zip files using phone's default App

Observed behaviour:-

  1. The files obtained ater extraction can't be viewed
  2. The extracted files are under the directory structure _compressedzip>data>user>0>com.example.MyProject>files. (which is the path of the file I picked from Asset folder) Ideally it should be directly under compressed_zip folder.

Please help me resolving in this issue and let me know if you need any more details from my side

asthagarg2428 commented 2 years ago

1st part I have resolved. Created separate issue for 2nd point

omicronapps commented 2 years ago

I can also recommend referring to the documentation for Java library 7-Zip-JBinding.

This includes the the documentation available here:

As well as the Java documentation for the library: