mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-19 13:57:51 -04:00
✨ Add support for declaring UploadFile parameters without explicit File() (#4469)
This commit is contained in:
committed by
GitHub
parent
59b1f353b3
commit
1bf55200a9
15
docs_src/request_files/tutorial001_03.py
Normal file
15
docs_src/request_files/tutorial001_03.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from fastapi import FastAPI, File, UploadFile
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.post("/files/")
|
||||
async def create_file(file: bytes = File(..., description="A file read as bytes")):
|
||||
return {"file_size": len(file)}
|
||||
|
||||
|
||||
@app.post("/uploadfile/")
|
||||
async def create_upload_file(
|
||||
file: UploadFile = File(..., description="A file read as UploadFile")
|
||||
):
|
||||
return {"filename": file.filename}
|
||||
Reference in New Issue
Block a user