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] = {} headers: Dict[str, str] = {}
for part in parts: for part in parts:
for header in part.headers: if data is not None:
if b'name="upload_file"' in header.value: for header in part.headers:
headers["key"] = "upload_file" if b'name="upload_file"' in header.value:
data = part.data headers["key"] = "upload_file"
else:
if b'name="file"' in header.value:
data = part.data data = part.data
break
else: 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"'], # 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(): # for prt in parser.parts():
@ -109,6 +113,7 @@ def get_body_from_form_data(
# data = val # data = val
# else: # else:
# headers[prt.name] = val.decode("utf-8") # headers[prt.name] = val.decode("utf-8")
print("YO HEADERS")
print("YO FINAL ", data, headers) print("YO FINAL ", data, headers)
return data, headers return data, headers