-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google "How to X in FastAPI" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
python
@router.post('/search', status_code=200)
async def search(size: int = 4, query: UploadFile = File(...)):
//bla blavar file = {
"height": 1536,
"type": "image/jpeg",
"uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Fceleb-29ac4ec3-be4e-439c-80d0-f29ada3c36aa/ImagePicker/3dc7f9fe-c0d3-4d2f-90e9-0b89fa8b1d72.jpg",
"width": 2048,
}
var query = new FormData();
query.append('query', file)
var result = await axios.post(`${apiurl}/search`, query, {
headers:{'content-type':'multipart/form-data'}
})
### Description
Confused when running the code in question fast api returns:
``` json
"_response":
"{
\"detail\": [{\"loc\":[\"body\",\"query\"],\"msg\":\"Expected UploadFile, received: <class 'str'>\",\"type\":\"value_error\"}]
}"
Looks like the formData is interpreted as a string?
Operating System
Linux
Operating System Details
No response
FastAPI Version
latest
Python Version
latest
Additional Context
No response