Reputation: 127
So I have a base64 string and wanting to decode into a file object and upload it with PySFTP. I'm getting an error:
'bytes' object has no attribute 'read'
Is my decoding wrong here?
fileObj = base64.b64decode(attach["payload"])
srv.putfo(fileObj, filename)
Upvotes: 1
Views: 1123
Reputation: 127
The Connection.putfo
takes a file-like object, not just "bytes":
fileObj = BytesIO(base64.b64decode(attach["payload"]))
Upvotes: 1