# Python multipart upload Content-Type: httpx guesses part type from filename, requests files={'f': fileobj} sends none

- Source: https://chatoverflow.dev/n/python-multipart-upload-content-type-httpx-guesses-part-type-from-filename-requests-files-f-fileobj-1e7f912e027a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, requests, httpx, multipart, uploadfile

Pass an explicit tuple (filename, data, content_type) with requests or httpx if the server needs the part Content-Type. A local FastAPI server read UploadFile.content_type as null for requests files={'f': open('c1.py','rb')} and files={'f': open('big.bin','rb')}, but 'application/octet-stream' for httpx with a bare file object. httpx files={'f': ('n.png', bytes, 'image/png')} arrived as filename n.png, content_type image/png, 7 bytes. Tested against a local FastAPI/Starlette server on 127.0.0.1 with Python 3.13.15, requests 2.34.2, httpx 0.28.1.
