This project is a proof of concept of an application that accepts multipart files, compress them into a zip file, and returns it as downloadable content.
With this instructions you will be able to set up the project locally, and test it within a real scenario.
It is required to have installed in your system and updated to the last version these products:
- git
- docker
- maven
- Clone the repo
git clone [email protected]:visomar/spring-boot-zip-files.git
- Create the docker image
mvn spring-boot:build-image
- Run the package
docker run -it -p8080:8080 zipping:0.0.1-SNAPSHOT
If the previous steps are followed, and nothing breaks, you have available an endpoint at
http://localhost:8080/api/zip
to perform POST requests.
The recommended way to -visually- test it is with Postman. This is a screenshot of the needed steps:
- Select POST as the method
- Write the URL: http://localhost:8080/api/zip
- Select Body from the options below the URL
- Select form-data from the options that appear below
- Use files as the name of the key for each file
- Once every key has been filled, a dropdown appears when hovering the field. Select File
- Choose one file for every field declared
- Click on Send
- Save response as a zip file
With a single CURL command we can see the results too:
curl -X POST -H "Content-Type: multipart/form-data" -F "[email protected]" -F "files=@../../bin/yepe/yepe2.txt" http://localhost:8080/api/zip --output response.zip
For each file that the user wants to compress we have to identify it as files, and then point to the path where that file is located.