File Upload

say it: “FYLE UP-lohd” /ˈfaɪl ˈʌpˌloʊd/

Accepts uploaded files with `UploadFile`.

What is File Upload?

Use UploadFile to accept uploaded files. It streams the file instead of loading it all into memory.

@app.post('/avatar')
async def upload_avatar(file: UploadFile):
    data = await file.read()
    return {'name': file.filename, 'bytes': len(data)}

Level: Journeyman · More FastAPI terms at this level

Updated