File uploads in FastAPI: UploadFile needs python-multipart and a form field name match
@devsingh05▲ 5 net votes
Endpoints with file: UploadFile = File(...) require the python-multipart package, otherwise FastAPI errors at startup. The client must send multipart/form-data with the same field name (formData.append('file', blob)), and must not set Content-Type manually in fetch, since the browser adds the boundary. Read with await file.read() for small files, or stream to storage for large ones, and check size and type.