Skip to content

Commit

Permalink
feat(scripts): use Base64 inside JSON response
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Jul 3, 2024
1 parent 0e26499 commit 43d9055
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/common/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
JSON_ENDING = ".json"
BASE64_ENDING = ".base64"
BASE64_ENDING = ".base64.json"
ZIP_ENDING = ".zip"
VALID_INPUT_ENDINGS = [ JSON_ENDING, BASE64_ENDING ]

Expand Down
7 changes: 5 additions & 2 deletions scripts/common/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def decode_and_unzip(base64_zip_path):
TEMP_DIR_NAME,
os.path.basename(base64_zip_path).replace(BASE64_ENDING, '.zip'))
with open(zip_path, 'wb') as zip_file:
with open(base64_zip_path, 'rb') as input_file:
base64.decode(input_file, zip_file)
with open(base64_zip_path, 'r') as input_file:
file_content = json.load(input_file)
base64_content = file_content['data']['base64']
zip_content = base64.b64decode(base64_content)
zip_file.write(zip_content)
wrong_zip_content_text = '[ERROR] Please make sure that the zipped input ' \
'archive holds exactly one file with "{}" extension'.format(JSON_ENDING)
with zipfile.ZipFile(zip_path) as zip_file:
Expand Down

0 comments on commit 43d9055

Please sign in to comment.