import json from pyinfra.server.packing import bytes_to_string from pyinfra.utils.encoding import compress def pack_for_upload(data: bytes): return compress(json.dumps(bytes_to_string(data)).encode())