I have this:
from io import StringIO
buffer = StringIO()
latest_file = 'C:\\Users\\miguel.santos\\Desktop\\meo_snapshots\\Snapshot_14.jpg'
buffer.write(open(latest_file,'rb').read())
TypeError: string argument expected, got 'bytes'
Any ideas on how to solve?
io.StringIO
is for unicode text, its counterpart for bytes is io.BytesIO
. As your undelying file is a binary jpg, you really should use the latter:
from io import BytesIO
buffer = BytesIO()
latest_file = 'C:\\Users\\miguel.santos\\Desktop\\meo_snapshots\\Snapshot_14.jpg'
buffer.write(open(latest_file,'rb').read())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With