Better logic

This commit is contained in:
Sky O 2024-03-29 17:53:44 +00:00
parent 0af367fd2d
commit 7eae837e24

View File

@ -88,15 +88,19 @@ def get_body_from_form_data(
headers: Dict[str, str] = {}
for part in parts:
for header in part.headers:
if b'name="upload_file"' in header.value:
headers["key"] = "upload_file"
data = part.data
else:
if b'name="file"' in header.value:
if data is not None:
for header in part.headers:
if b'name="upload_file"' in header.value:
headers["key"] = "upload_file"
data = part.data
break
else:
headers["file"] = part.data.decode("utf-8")
if b'name="file"' in header.value:
data = part.data
break
else:
headers["file"] = part.data.decode("utf-8")
break
# name="x-amz-algorithm"', b'Content-Disposition':b'form-data; name="x-amz-credential"', b'Content-Disposition':b'form-data; name="x-amz-date"', b'Content-Disposition':b'form-data; name="policy"', b'Content-Disposition':b'form-data; name="x-amz-signature"', b'Content-Disposition':b'form-data; name="file"; filename="/run/user/1001/tmpi1gf2n_j/test_local_file.txt"'],
# for prt in parser.parts():
@ -109,6 +113,7 @@ def get_body_from_form_data(
# data = val
# else:
# headers[prt.name] = val.decode("utf-8")
print("YO HEADERS")
print("YO FINAL ", data, headers)
return data, headers