Skip to content

Instantly share code, notes, and snippets.

@pashri
Created August 3, 2021 10:36
Show Gist options
  • Save pashri/55dfca4803640582a3d7acb5eb5684f3 to your computer and use it in GitHub Desktop.
Save pashri/55dfca4803640582a3d7acb5eb5684f3 to your computer and use it in GitHub Desktop.
Decode that base64 encoded gzipped json from AWS
import gzip
import base64
import io
import json
import pprint
def decode_mystery_message_from_aws(data: str) -> list:
"""Decodes a mystery message from AWS"""
decoded_data = base64.b64decode(data)
bytes_obj_data = io.BytesIO(decoded_data)
with gzip.open(bytes_obj_data, 'rb') as unzipped_data:
message = [
json.loads(line.decode())
for line in unzipped_data
]
return message
pprint.pprint(next(iter(decode_mystery_message_from_aws(data))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment