A utility that split compressed files into a set of compressed files such that each compressed file doesn't exceed a maximum size. It is written in Java 11 and build using Gradle.
🐳 DockerHub: desi109/zip-splitter
If you have not got Java installed already, please install it, or alternatively you can run the application using Docker.
Either of the following methods can be used to set up the application as desired.
- Build the JAR file using gradle, the output zip-splitter.jar would be in /build/libs directory in the project folder.
gradle clean build
- Run the application with desired arguments. To split zip:
java -jar build/libs/zip-splitter.jar -zipPath=<zip-path> -maxSizeInMB=<max-size-in-MB> -outputPath=<output-path>
Example command:
java -jar build/libs/zip-splitter.jar -zipPath=/home/user/test-resources/zip-before-split/test.zip -maxSizeInMB=150 -outputPath=/home/user/test-resources/zips-after-split
The idea is to run the application leveraging docker volumes for mapping host directories to be split.
- Build the docker image from project directory:
The build might take some time as it would download the image and gradle dependencies. Verify that the build was successful and proceed.
sudo docker build -t zip-splitter .
- Run the application with desired args. To split zip:
When we run docker commands with
sudo docker run -v <local-system-path-to-the-zip-folder>:/zip-before-split -v <local-system-path-to-the-output-folder>:/zips-after-split zip-splitter java -jar /build/libs/zip-splitter.jar -zipPath=/zip-before-split/test.zip -maxSizeInMB=150 -outputPath=/zips-after-split
sudo
, we may need to change the permissions of the zip files at the end.Example command:cd <local-system-path-to-the-zip-folder> chmod -R 757 .
sudo docker run -v /home/user/test-resources/zip-before-split:/zip-before-split -v /home/user/test-resources/zips-after-split:/zips-after-split zip-splitter java -jar /build/libs/zip-splitter.jar -zipPath=/zip-before-split/test.zip -maxSizeInMB=150 -outputPath=/zips-after-split cd /home/user/test-resources/zips-after-split chmod -R 757 .
The idea is to run the application leveraging docker volumes for mapping host directories to be split.
- Pull the image from DockerHub:
sudo docker pull desi109/zip-splitter:latest
- Run the application with desired args. To split zip:
When we run docker commands with
sudo docker run -v <local-system-path-to-the-zip-folder>:/zip-before-split -v <local-system-path-to-the-output-folder>:/zips-after-split zip-splitter java -jar /build/libs/zip-splitter.jar -zipPath=/zip-before-split/test.zip -maxSizeInMB=150 -outputPath=/zips-after-split
sudo
, we may need to change the permissions of the zip files at the end.Example command:cd <local-system-path-to-the-zip-folder> chmod -R 757 .
sudo docker run -v /home/user/test-resources/zip-before-split:/zip-before-split -v /home/user/test-resources/zips-after-split:/zips-after-split zip-splitter java -jar /build/libs/zip-splitter.jar -zipPath=/zip-before-split/test.zip -maxSizeInMB=150 -outputPath=/zips-after-split cd /home/user/test-resources/zips-after-split chmod -R 757 .
NOTE:
- By default, the application runs with a single thread.
TODOs:
- Add tests.
- All the files in a zip to be recompressed in a multithreaded fashion.