BigW Consortium Gitlab

Commit 1a356482 by Marc Abramowitz

Change file check from isinstance(value, file) to hasattr(value, 'read') so that…

Change file check from isinstance(value, file) to hasattr(value, 'read') so that file-like objects are handled. - if isinstance(value, file): - file_object = value - files.append((name, file_object.name, file_object.read())) + if hasattr(value, 'read'): + files.append((name, value.name, value.read()))
parent 88360b4e
......@@ -315,9 +315,8 @@ class API(object):
files = []
for name, value in kwargs.items():
if isinstance(value, file):
file_object = value
files.append((name, file_object.name, file_object.read()))
if hasattr(value, 'read'):
files.append((name, value.name, value.read()))
else:
fields.append((name, str(value)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment