Skip to content

Commit d83bf13

Browse files
committed
Fix bug in base64 padding that made img uploads unreadable
1 parent 6f31040 commit d83bf13

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

synapse_pay_rest/models/users/physical_document.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ def create(cls, base_document, value=None, type=None, file_path=None,
4646
def byte_stream_to_base64(byte_stream, mime_type):
4747
"""Convert a byte stream / array to a properly padded base64 string.
4848
"""
49-
encoded_string = str(base64.b64encode(byte_stream))
49+
base64_string = base64.b64encode(byte_stream).decode("utf-8")
5050
mime_padding = 'data:{0};base64,'.format(mime_type)
51-
base64_string = mime_padding + encoded_string
52-
return base64_string
51+
padded_base64 = mime_padding + base64_string
52+
return padded_base64
5353

5454
@staticmethod
5555
def file_to_base64(file_path):

0 commit comments

Comments
 (0)