Debian Codegraph @

docs/examples/request_data/request_data_10.py

raw
1 from typing import Any, Dict, List, Tuple
2
3 from litestar import Litestar, post
4 from litestar.datastructures import UploadFile
5 from litestar.params import MultipartBody
6
7
8 @post(path="/")
9 async def handle_file_upload(
10 data: MultipartBody[List[UploadFile]],
11 ) -> Dict[str, Tuple[str, str, Any]]:
12 result = {}
13
14 for file in data:
15 content = await file.read()
16 result[file.filename] = (len(content), file.content_type, file.headers)
17
18 return result
19
20
21 app = Litestar(route_handlers=[handle_file_upload])