22 lines
545 B
Python
22 lines
545 B
Python
import io
|
|
|
|
|
|
class UploadedFile:
|
|
def __init__(self, filename: str = None):
|
|
self.filename = filename
|
|
self.body_b64 = io.BytesIO()
|
|
|
|
|
|
def from_bytes(input_bytes: bytes) -> UploadedFile:
|
|
"""
|
|
Builds the UploadedFile from its serialized (byte array) form.
|
|
:param input_bytes: serialized message
|
|
:return: UploadedFile instance
|
|
"""
|
|
prolog_len = (input_bytes[0] << 8) + input_bytes[1]
|
|
metadata = input_bytes[2:prolog_len + 2].decode()
|
|
body_b64 = input_bytes[prolog_len + 2:]
|
|
|
|
return UploadedFile()
|
|
|