|
48 | 48 | async_to_custom_streamed_response_wrapper, |
49 | 49 | ) |
50 | 50 | from ...._base_client import make_request_options |
| 51 | +from ....lib.multipart import indexed_multipart_body |
51 | 52 | from ....types.browsers import ( |
52 | 53 | f_move_params, |
53 | 54 | f_upload_params, |
@@ -510,14 +511,19 @@ def upload( |
510 | 511 | raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
511 | 512 | extra_headers = {"Accept": "*/*", **(extra_headers or {})} |
512 | 513 | body = deepcopy_with_paths({"files": files}, [["files", "<array>", "file"]]) |
513 | | - extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>", "file"]]) |
| 514 | + # The remote filesystem pairs each file part with the sibling fields of the |
| 515 | + # same array entry, so both halves of the form use indexed names |
| 516 | + # (`files[0][file]`, `files[0][dest_path]`). |
| 517 | + extracted_files = extract_files( |
| 518 | + cast(Mapping[str, object], body), paths=[["files", "<array>", "file"]], array_format="indices" |
| 519 | + ) |
514 | 520 | # It should be noted that the actual Content-Type header that will be |
515 | 521 | # sent to the server will contain a `boundary` parameter, e.g. |
516 | 522 | # multipart/form-data; boundary=---abc-- |
517 | 523 | extra_headers["Content-Type"] = "multipart/form-data" |
518 | 524 | return self._post( |
519 | 525 | path_template("/browsers/{id}/fs/upload", id=id), |
520 | | - body=maybe_transform(body, f_upload_params.FUploadParams), |
| 526 | + body=indexed_multipart_body(maybe_transform(body, f_upload_params.FUploadParams)), |
521 | 527 | files=extracted_files, |
522 | 528 | options=make_request_options( |
523 | 529 | extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
@@ -1073,14 +1079,19 @@ async def upload( |
1073 | 1079 | raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
1074 | 1080 | extra_headers = {"Accept": "*/*", **(extra_headers or {})} |
1075 | 1081 | body = deepcopy_with_paths({"files": files}, [["files", "<array>", "file"]]) |
1076 | | - extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>", "file"]]) |
| 1082 | + # The remote filesystem pairs each file part with the sibling fields of the |
| 1083 | + # same array entry, so both halves of the form use indexed names |
| 1084 | + # (`files[0][file]`, `files[0][dest_path]`). |
| 1085 | + extracted_files = extract_files( |
| 1086 | + cast(Mapping[str, object], body), paths=[["files", "<array>", "file"]], array_format="indices" |
| 1087 | + ) |
1077 | 1088 | # It should be noted that the actual Content-Type header that will be |
1078 | 1089 | # sent to the server will contain a `boundary` parameter, e.g. |
1079 | 1090 | # multipart/form-data; boundary=---abc-- |
1080 | 1091 | extra_headers["Content-Type"] = "multipart/form-data" |
1081 | 1092 | return await self._post( |
1082 | 1093 | path_template("/browsers/{id}/fs/upload", id=id), |
1083 | | - body=await async_maybe_transform(body, f_upload_params.FUploadParams), |
| 1094 | + body=indexed_multipart_body(await async_maybe_transform(body, f_upload_params.FUploadParams)), |
1084 | 1095 | files=extracted_files, |
1085 | 1096 | options=make_request_options( |
1086 | 1097 | extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
|
0 commit comments