From 7eae837e2487993e2970ca83d1b9b337c0103955 Mon Sep 17 00:00:00 2001 From: Sky O Date: Fri, 29 Mar 2024 17:53:44 +0000 Subject: [PATCH] Better logic --- moto/moto_proxy/utils.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/moto/moto_proxy/utils.py b/moto/moto_proxy/utils.py index 2481a51d9..1667a919e 100644 --- a/moto/moto_proxy/utils.py +++ b/moto/moto_proxy/utils.py @@ -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