Skip to content

Commit

Permalink
Add notes on "filename" form-data field (#1704)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 27, 2022
1 parent d69dc54 commit 92c1f1e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/requests.md
Expand Up @@ -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

Expand Down

0 comments on commit 92c1f1e

Please sign in to comment.