In python3 a bytes object needs to be decoded after image upload

This commit is contained in:
Maks Kolman
2016-12-16 17:09:56 +01:00
parent 65fbb77451
commit c7534ec32b

View File

@@ -323,6 +323,8 @@ class Client(object):
:param image: a tuple of (file name, data, mime type) to upload to facebook
"""
r = self._postFile(UploadURL, image)
if isinstance(r._content, str) is False:
r._content = r._content.decode("utf-8")
# Strip the start and parse out the returned image_id
return json.loads(r._content[9:])['payload']['metadata'][0]['image_id']