Last active
March 8, 2020 20:37
-
-
Save narenaryan/c8e9e8263832b78aec3d527d21c5e25f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from zipfile import ZipFile | |
| from io import BytesIO | |
| def create_zip_v1(): | |
| """ | |
| returns: zip archive | |
| """ | |
| archive = BytesIO() | |
| with ZipFile(archive, 'w') as zip_archive: | |
| # Create three files on zip archive | |
| with zip_archive.open('docker/docker-compose.yaml', 'w') as file1: | |
| file1.write(b'compose-file-content...') | |
| with zip_archive.open('app/app-config.json', 'w') as file2: | |
| file2.write(b'app-config-content...') | |
| with zip_archive.open('root-config.json', 'w') as file3: | |
| file3.write(b'root-config-content...') | |
| return archive | |
| archive = create_zip_v1() | |
| # Flush archive stream to a file on disk | |
| with open('config.zip', 'wb') as f: | |
| f.write(archive.getbuffer()) | |
| archive.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment