I’m getting an error when I use a tempfile.TemporaryFile and pass it to client.media.upload
If I use a vanilla filehandle with open() everything works.
example - this works:
tempfh = open('/tmp/tempfile', 'wb') tempfh.write(field.data) tempfh.close() #reopen? tempfh = open('/tmp/tempfile', 'rb') uploadTokenId = client.media.upload(tempfh)
This does not work:
import tempfile tempfh = tempfile.TemporaryFile(mode="w+b") tempfh.write(field.data) tempfh.seek(0) uploadTokenId = client.media.upload(tempfh)
*** KalturaClient.exceptions.KalturaClientException: expected string or bytes-like object (-4)
Both are file like objects and both have ‘read’ and ‘readlines’ methods and should be treated the same way.
Anyone also experience this? Anyway I can avoid the write to disk just to create a filehandle that the API seems to like?
Seems like a bug to me.