From cb717fe7490d304f858f00b459166f8b42900300 Mon Sep 17 00:00:00 2001 From: Khazhismel Date: Wed, 2 Dec 2015 20:45:17 -0500 Subject: [PATCH 1/2] Allow uploading file-like objects, allowing uploading of BytesIO/etc. --- imgurpython/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imgurpython/client.py b/imgurpython/client.py index b860a1a..9c41ea6 100644 --- a/imgurpython/client.py +++ b/imgurpython/client.py @@ -580,10 +580,13 @@ def get_image(self, image_id): return Image(image) def upload_from_path(self, path, config=None, anon=True): + with open(path, 'rb') as fd: + self.upload(fd, config, anon) + + def upload(self, fd, config=None, anon=True): if not config: config = dict() - fd = open(path, 'rb') contents = fd.read() b64 = base64.b64encode(contents) data = { @@ -591,7 +594,6 @@ def upload_from_path(self, path, config=None, anon=True): 'type': 'base64', } data.update({meta: config[meta] for meta in set(self.allowed_image_fields).intersection(config.keys())}) - fd.close() return self.make_request('POST', 'upload', data, anon) From 1cd23bc471c1682247e9e5afece3305073befd26 Mon Sep 17 00:00:00 2001 From: Kevin Cramer Date: Thu, 19 Oct 2017 13:14:04 -0700 Subject: [PATCH 2/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 999a987..c89b846 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# The imgurpython project is no longer supported. + imgurpython ===========