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