[Python] Add Support for Content-Disposition Header without filename (#11055)

* [Python] Add Support for CD header w/o filename

* updated documentation per PR instructions

* fixed formatting and updated samples and docs

* revert docs changes

* regenerate python samples

* updated sample python test
This commit is contained in:
Cameron Koegel
2022-03-08 12:10:49 -05:00
committed by GitHub
parent b1c6513015
commit 94b1440074
7 changed files with 83 additions and 37 deletions

View File

@@ -16,6 +16,7 @@ import os
import pprint
import re
import tempfile
import uuid
from dateutil.parser import parse
@@ -1399,7 +1400,13 @@ def deserialize_file(response_data, configuration, content_disposition=None):
if content_disposition:
filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?',
content_disposition).group(1)
content_disposition,
flags=re.I)
if filename is not None:
filename = filename.group(1)
else:
filename = "default_" + str(uuid.uuid4())
path = os.path.join(os.path.dirname(path), filename)
with open(path, "wb") as f: