You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/event_handler/api_gateway.md
+5-34Lines changed: 5 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -523,47 +523,18 @@ In the following example, we use a new `Header` OpenAPI type to add [one out of
523
523
524
524
1. `cloudfront_viewer_country` is a list that must contain values from the `CountriesAllowed` enumeration.
525
525
526
-
#### Handling file uploads and form data
526
+
#### Handling form data
527
527
528
528
!!! info "You must set `enable_validation=True` to handle file uploads and form data via type annotation."
529
529
530
-
We use the `Annotated` type to tell the Event Handler that a parameter expects file upload or form data. This automatically sets the correct OpenAPI schema for `multipart/form-data` requests.
530
+
You can use the `Form` type to tell the Event Handler that a parameter expects file upload or form data. This automatically sets the correct OpenAPI schema for `application/x-www-form-urlencoded` requests.
531
531
532
-
In the following example, we use `File` and `Form` OpenAPI types to handle file uploads and form fields:
532
+
=== "working_with_form_data.py"
533
533
534
-
*`File` parameters expect binary file data and generate OpenAPI schema with `format: binary`
535
-
*`Form` parameters expect form field values from multipart form data
536
-
* The OpenAPI spec will automatically set `requestBody` content type to `multipart/form-data`
1. If you're not using Python 3.9 or higher, you can install and use [`typing_extensions`](https://pypi.org/project/typing-extensions/){target="_blank" rel="nofollow"} to the same effect
545
-
2. `File` is a special OpenAPI type for binary file uploads that sets `format: binary` in the schema
546
-
3. `Form` is a special OpenAPI type for form field values in multipart requests
547
-
548
-
=== "Multiple files"
549
-
550
-
You can handle multiple file uploads by declaring parameters as lists:
0 commit comments