File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
src/main/resources/handlebars/python Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -530,10 +530,14 @@ class ApiClient(object):
530
530
filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?',
531
531
content_disposition).group(1)
532
532
path = os.path.join(os.path.dirname(path), filename)
533
-
534
- with open(path, "wb") as f:
535
- f.write(response.data)
536
-
533
+ response_data = response.data
534
+ with open(path, "wb") as f:
535
+ if isinstance(response_data, str):
536
+ # change str to bytes so we can write it
537
+ response_data = response_data.encode('utf-8')
538
+ f.write(response_data)
539
+ else:
540
+ f.write(response_data)
537
541
return path
538
542
539
543
def __deserialize_primitive(self, data, klass):
Original file line number Diff line number Diff line change @@ -207,11 +207,6 @@ class RESTClientObject(object):
207
207
if _preload_content:
208
208
r = RESTResponse(r)
209
209
210
- # In the python 3, the response.data is bytes.
211
- # we need to decode it to string.
212
- if six.PY3:
213
- r.data = r.data.decode('utf8')
214
-
215
210
# log response body
216
211
logger.debug("response body: %s", r.data)
217
212
You can’t perform that action at this time.
0 commit comments