if text and not os.path.isfile(src):
# src is text input that should be uploaded as file
# create a temporal file with the content to upload
- f = tempfile.NamedTemporaryFile(delete=False)
+ # in python3 we need to open in binary mode if str is bytes
+ mode = 'w' if isinstance(src, str) else 'wb'
+ f = tempfile.NamedTemporaryFile(mode=mode, delete=False)
f.write(src)
f.close()
src = f.name