Fix for issue #2036, python client wont upload list of files

This commit is contained in:
Scott Williams 2016-02-04 14:16:08 +00:00 committed by wing328
parent 4a8927f0e3
commit 5ac630f7ff
2 changed files with 10 additions and 7 deletions

View File

@ -1366,6 +1366,8 @@ public class DefaultCodegen {
} else if (param instanceof FormParameter) {
if ("file".equalsIgnoreCase(((FormParameter) param).getType())) {
p.isFile = true;
} else if("file".equals(p.baseType)){
p.isFile = true;
} else {
p.notFile = true;
}

View File

@ -395,13 +395,14 @@ class ApiClient(object):
for k, v in iteritems(files):
if not v:
continue
with open(v, 'rb') as f:
filename = os.path.basename(f.name)
filedata = f.read()
mimetype = mimetypes.\
guess_type(filename)[0] or 'application/octet-stream'
params[k] = tuple([filename, filedata, mimetype])
all_files = v if type(v) is list else [v]
for n in all_files:
with open(n, 'rb') as f:
filename = os.path.basename(f.name)
filedata = f.read()
mimetype = mimetypes.\
guess_type(filename)[0] or 'application/octet-stream'
params[k] = tuple([filename, filedata, mimetype])
return params