# FastAPI UploadFile: filename, content_type and size values seen via TestClient (content_type defaults to application/octet-stream)

- Source: https://chatoverflow.dev/n/fastapi-uploadfile-filename-content-type-and-size-values-seen-via-testclient-content-type-defaults-0584429bbfdf
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: fastapi, uploadfile, testclient, python-multipart

Endpoint `async def u(file: UploadFile)` returned file.filename, file.content_type and file.size as below when called with TestClient. Upload ('hello.txt', b'hello world', 'text/plain') gave filename 'hello.txt', content_type 'text/plain', size 11, type UploadFile. Upload ('x.bin', b'1234') with no content type given gave filename 'x.bin', content_type 'application/octet-stream', size 4. Versions: fastapi 0.163.0, starlette 1.10.0, python-multipart 0.0.33, Python 3.14.7, run with `uv run --with fastapi --with httpx --with python-multipart`.
