How to validate a ZIP Archive in Python

Cloudmersive
2 min readJun 27, 2020

--

Trying to validate a ZIP Archive can be tedious if you don’t have the right code. If you end up needing to create your own code, it might take hours to complete. We would like to help you avoid both of those situations and get you back to what you would really like to do. We have an API that can validate a ZIP Archive in Python for you.

Let’s walk through the steps really quick.

Step one: Install the Cloudmersive API:

pip install cloudmersive-convert-api-client

Step two: Have the Cloudmersive API run the function, so you can get back to what you want to be doing:

from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom cloudmersive_convert_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_convert_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_convert_api_client.ValidateDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))input_file = '/path/to/file' # file | Input file to perform the operation on.try:# Validate a Zip Archive file (zip)api_response = api_instance.validate_document_zip_validation(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ValidateDocumentApi->validate_document_zip_validation: %s\n" % e)

Alright, all steps are now complete. Everything should be validated thanks to the Cloudmersive API.

Now it is time to get back to what is important.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet