From 672cfbdb5bf141909cc49577811a081c28d168e8 Mon Sep 17 00:00:00 2001 From: Harry Python <31451509+harrypython@users.noreply.github.com> Date: Mon, 11 Dec 2017 12:36:28 -0800 Subject: [PATCH] Autopost "I/O operation on closed file" Autopost wont work. Get a msg "I/O operation on closed file" https://github.com/instagrambot/instabot/issues/412 --- api_photo.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api_photo.py b/api_photo.py index 0bd3a75..ee0bb61 100644 --- a/api_photo.py +++ b/api_photo.py @@ -62,14 +62,14 @@ def uploadPhoto(self, photo, caption=None, upload_id=None): if not compatibleAspectRatio(getImageSize(photo)): self.logger.info('Not compatible photo aspect ratio') return False - with open(photo, 'rb') as photo_bytes: - data = { - 'upload_id': upload_id, - '_uuid': self.uuid, - '_csrftoken': self.token, - 'image_compression': '{"lib_name":"jt","lib_version":"1.3.0","quality":"87"}', - 'photo': ('pending_media_%s.jpg' % upload_id, photo_bytes, 'application/octet-stream', {'Content-Transfer-Encoding': 'binary'}) - } + + data = { + 'upload_id': upload_id, + '_uuid': self.uuid, + '_csrftoken': self.token, + 'image_compression': '{"lib_name":"jt","lib_version":"1.3.0","quality":"87"}', + 'photo': ('pending_media_%s.jpg' % upload_id, open(photo, 'rb'), 'application/octet-stream', {'Content-Transfer-Encoding': 'binary'}) + } m = MultipartEncoder(data, boundary=self.uuid) self.session.headers.update({'X-IG-Capabilities': '3Q4=', 'X-IG-Connection-Type': 'WIFI',