main
md 47 lines 1.99 KB
Rendered Raw
1 # upload.py DOX
2
3 ## Purpose
4
5 - Own the `upload.py` API endpoint.
6 - This module accepts general uploads into runtime upload storage.
7 - Keep this file-level DOX profile synchronized with `upload.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `upload.py` owns the runtime implementation.
12 - `upload.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `UploadFile` (`ApiHandler`)
15 - `async process(self, input: dict, request: Request) -> dict | Response`
16 - `allowed_file(self, filename)`
17
18 ## Runtime Contracts
19
20 - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`.
21 - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change.
22 - `UploadFile` is an `ApiHandler`.
23 - `UploadFile` defines `process(...)`.
24 - Observed side-effect areas: filesystem reads, settings/state persistence.
25 - Imported dependency areas include: `helpers`, `helpers.api`, `helpers.security`.
26
27 ## Key Concepts
28
29 - Important called helpers/classes observed in the source: `request.files.getlist`, `Exception`, `self.allowed_file`, `safe_filename`, `file.save`, `files.get_abs_path`.
30 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
31
32 ## Work Guidance
33
34 - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes.
35 - Update frontend callers, plugin callers, and tests together when payload shape changes.
36 - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies.
37
38 ## Verification
39
40 - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists.
41 - Related tests observed by source search:
42 - `tests/test_browser_agent_regressions.py`
43 - `tests/test_image_get_security.py`
44
45 ## Child DOX Index
46
47 No child DOX files.