Try matching

This commit is contained in:
Sky O 2024-03-29 18:34:05 +00:00
parent 80b722e677
commit ff5dfc1489

View File

@ -1,5 +1,6 @@
from typing import Dict, Optional, Tuple from typing import Dict, Optional, Tuple
import re
import multipart import multipart
class Part: class Part:
@ -88,7 +89,6 @@ def get_body_from_form_data(
headers: Dict[str, str] = {} headers: Dict[str, str] = {}
for part in parts: for part in parts:
if data is None:
for header in part.headers: for header in part.headers:
print("YO CHECKING ", header.value) print("YO CHECKING ", header.value)
if b'name="upload_file"' in header.value: if b'name="upload_file"' in header.value:
@ -100,7 +100,12 @@ def get_body_from_form_data(
data = part.data data = part.data
print("YO SETTING FILE") print("YO SETTING FILE")
else: else:
headers["file"] = part.data.decode("utf-8") match = re.search(r'name="([^"]*)"', header.value)
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") 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"'], # 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"'],