feat(upload): 支持 Agent 本地图片安全上传

This commit is contained in:
yuzhe
2026-07-23 13:26:10 +08:00
parent 69cfd0b51d
commit c067881415
12 changed files with 380 additions and 25 deletions

View File

@@ -51,7 +51,7 @@ Returns current work content, project identity, images, and rounds. Use `?round=
### `POST /api/projects/:projectId/works`
JSON body:
URL mode uses a JSON body:
```json
{
@@ -72,6 +72,15 @@ Constraints:
- Cross-origin images must be supported image responses no larger than 20 MB. Local, private, reserved, and non-standard-port targets are rejected.
- Repeating the same `projectId + externalId` returns the existing work with `idempotent: true`.
Local-file mode uses `multipart/form-data` with text fields `externalId`, `title`, `description`, `tags` and repeated file field `images`.
- Send `tags` as a JSON array string.
- Send 1-30 JPEG, PNG, GIF, WebP, or AVIF files, each no larger than 20 MB.
- File order is display order; file 1 is the cover.
- The server validates actual image content instead of trusting only the filename or declared MIME.
- With active Tencent COS configuration, accepted files are streamed from server temporary storage into COS.
- Do not send Base64 in JSON. The agent script reads local files directly into the multipart request; binary bytes never belong in the plan or conversation.
### `POST /api/works/:workId/rounds`
JSON body:
@@ -87,6 +96,7 @@ JSON body:
This endpoint is not idempotent. One successful call creates exactly one new round. Never blindly retry after a timeout.
It applies the same COS reuse/import rules as work creation.
It also accepts the same local-file multipart fields, except `externalId` is omitted.
## State guards