I am not able to reproduce the exact output (‘content’) of the dcc.Upload component.
If I upload the file
my_excel.xlsx to the dcc.Upload component, my callback receives a “base64 encoded string” (according to the dcc.Upload documentation). I don’t know how to reproduce the exact same string without the dcc.Upload component.
my current approach:
with open('tests/data/my_excel.xlsx', 'rb') as file: raw_data = file.read() _, content_string = raw_data.split(',') # this Fails
I get the error
TypeError: a bytes-like object is required, not 'str'
if I add
raw_data = base64.b64encode(raw_data)
before the split, I get the same error.
How do I get the exact same “base64 encoded string” without the dcc.Upload Component?
Thanks very much in advance