Skip to content

feat(media): add validated upload adapter - #111

Open
xyh202131 wants to merge 1 commit into
1024XEngineer:mainfrom
xyh202131:feat/media-upload
Open

feat(media): add validated upload adapter#111
xyh202131 wants to merge 1 commit into
1024XEngineer:mainfrom
xyh202131:feat/media-upload

Conversation

@xyh202131

Copy link
Copy Markdown

Summary

  • add a real multipart media upload adapter for POST /media/upload
  • validate the response envelope and media DTO before returning MediaReference
  • expose the adapter through the Entity public entrypoint
  • propagate HTTP, business, contract and abort errors without mock success
  • fail explicitly when VITE_API_BASE_URL is missing instead of posting to the visitor's localhost

Scope

Frontend only. No page, WorkflowRun, Controller, backend, object-storage configuration, database, log or build artifact is included.

Verification

  • changed-file format check: passed
  • lint: passed
  • typecheck: passed
  • tests: 3 files, 14 tests passed
  • production build: passed
  • repository-wide format:check remains blocked by 41 pre-existing files on main; this PR does not mix those unrelated rewrites into the upload feature

Closes #109

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
windup Ready Ready Preview Aug 4, 2026 8:07am

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue found: the upload helper currently turns aborts that happen while reading the response body into UploadRequestError, so cancellation is no longer distinguishable from a real failure after fetch has resolved.

async function readResponseBody(response: Response): Promise<unknown> {
try {
return await response.json()
} catch {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.json() can reject with AbortError if the request is cancelled after the headers arrive but before the body is consumed. This catch block wraps every rejection as UploadRequestError, which contradicts the documented abort behavior and makes late cancellations look like upload failures. Re-throw aborts here (or special-case DOMException.name === 'AbortError') so callers can still handle cancellation separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 实现前端媒体上传适配与错误边界(Refs #70)

1 participant