mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-17 10:28:30 -05:00
* ✨ Add support for UploadFile annotations * 📝 Update File upload docs with FileUpload class * ✅ Add tests for UploadFile support * 📝 Update UploadFile docs
14 lines
297 B
Python
14 lines
297 B
Python
from fastapi import FastAPI, File, UploadFile
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.post("/files/")
|
|
async def create_file(file: bytes = File(...)):
|
|
return {"file_size": len(file)}
|
|
|
|
|
|
@app.post("/uploadfile/")
|
|
async def create_upload_file(file: UploadFile = File(...)):
|
|
return {"filename": file.filename}
|