Skip to content

Commit

Permalink
Support for filetypes in Python 3 version
Browse files Browse the repository at this point in the history
Also allow for `StringIO` type variables

Signed-off-by: hjpotter92 <hjpotter92+github@gmail.com>
  • Loading branch information
hjpotter92 committed Sep 27, 2017
1 parent a3df849 commit 1a5b9f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion redminelib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ def upload(self, filepath_obj):

url = '{0}/uploads.json'.format(self.url)
headers = {'Content-Type': 'application/octet-stream'}
if isinstance(filepath_obj, file):
try:
from StringIO import StringIO
filetype = (file, StringIO)
except (NameError, ImportError):
from io import IOBase
filetype = IOBase
if isinstance(filepath_obj, filetype):
response = self.engine.request('post', url, data=filepath_obj, headers=headers)
else:
if not os.path.isfile(filepath_obj) or os.path.getsize(filepath_obj) == 0:
Expand Down

0 comments on commit 1a5b9f1

Please sign in to comment.