]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Add notes on "filename" form-data field (#1704)
authormemsuser <108115586+memsuser@users.noreply.github.com>
Mon, 27 Jun 2022 04:56:00 +0000 (23:56 -0500)
committerGitHub <noreply@github.com>
Mon, 27 Jun 2022 04:56:00 +0000 (21:56 -0700)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
docs/requests.md

index 87294663837f8b03987641ba6f2826594a7969a8..a50c0753f360f7ae91e22d687c327d8537946185 100644 (file)
@@ -142,6 +142,13 @@ filename = form["upload_file"].filename
 contents = await form["upload_file"].read()
 ```
 
+!!! info
+    As settled in [RFC-7578: 4.2](https://www.ietf.org/rfc/rfc7578.txt), form-data content part that contains file 
+    assumed to have `name` and `filename` fields in `Content-Disposition` header: `Content-Disposition: form-
+    data; name="user"; filename="somefile"`. Though `filename` field is optional according to RFC-7578, it helps 
+    Starlette to differentiate which data should be treated as file. If `filename` field was supplied, `UploadFile` 
+    object will be created to access underlying file, otherwise form-data part will be parsed and available as a raw 
+    string.
 
 #### Application