We work I guess...

This commit is contained in:
Sky O 2024-03-29 19:05:53 +00:00
parent 34c00895c6
commit 90ac4e9409

View File

@ -84,43 +84,22 @@ def get_body_from_form_data(
parser.write(body)
parser.finalize()
print("YO PARTS", parts)
data = None
headers: Dict[str, str] = {}
for part in parts:
for header in part.headers:
print("YO CHECKING ", header.value)
if b'name="upload_file"' in header.value:
headers["key"] = "upload_file"
data = part.data
print("YO SET UPLOAD FILE")
else:
if b'name="file"' in header.value:
data = part.data
print("YO SETTING FILE")
else:
match = re.search(r'name="([^"]*)"', header.value.decode("utf-8"))
if match:
name = match.group(1)
print("YO GOT NAME", name)
headers[name] = part.data.decode("utf-8")
print("YO AYY")
print("YO COPING OUT")
# 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():
# if prt.name == "upload_file":
# headers["key"] = prt.name
# data = prt.file.read()
# else:
# val = prt.file.read()
# if prt.name == "file":
# data = val
# else:
# headers[prt.name] = val.decode("utf-8")
print("YO HEADERS", headers)
print("YO DATA ", data)
return data, headers
# form_data file