Skip to content

feat(webui): add file upload for mobile/remote devices (Fixes #1233)#1241

Merged
piorpua merged 4 commits intoiOfficeAI:mainfrom
audichuang:feat/webui-file-upload-v2
Mar 18, 2026
Merged

feat(webui): add file upload for mobile/remote devices (Fixes #1233)#1241
piorpua merged 4 commits intoiOfficeAI:mainfrom
audichuang:feat/webui-file-upload-v2

Conversation

@audichuang
Copy link
Copy Markdown
Contributor

Summary

Implements file upload for WebUI (mobile/remote devices) as specified in #1233.

What Changed

BackendPOST /api/upload

  • multer memory storage with 30 MB limit and LIMIT_FILE_SIZE → 413 handler
  • sanitizeFileName (path-traversal protection, CJK filename decoding)
  • resolveUploadWorkspace: validates conversation workspace from DB, rejects mismatches
  • Duplicate filenames get _aionui_<timestamp> suffix
  • Files written to {workspace}/uploads/

Frontend – SendBox

  • New FileAttachButton component: Electron → original button; WebUI → dropdown with Host Machine Files / My Device
  • All 5 SendBox variants (Acp, Codex, Gemini, Nanobot, OpenClaw) unified to use FileAttachButton
  • sendbox.tsx passes conversationId to useDragUpload and usePasteService

Frontend – Services

  • FileService.uploadFileViaHttp: client-side size guard + fetch multipart upload
  • FileService.processDroppedFiles: platform-aware (Electron IPC vs WebUI HTTP)
  • PasteService.createTempFile: unified helper for both platforms
  • buildDisplayMessage: preserve uploads/ subdirectory for workspace-internal paths

Frontend – Workspace

  • useWorkspacePaste: new handleUploadDeviceFiles (hidden <input> for browser file picker)
  • useWorkspaceDragImport: passes conversationId for WebUI HTTP uploads
  • workspace/index.tsx: WebUI-only + toolbar button with dropdown

i18n – 6 new keys across 6 languages (en/zh-CN/zh-TW/ja/ko/tr)

Tests – 10 unit tests (4 for resolveUploadWorkspace, 6 for buildDisplayMessage)

Security

  • CSRF exempted for /api/upload (multipart incompatible with tiny-csrf; protected by API token auth + rate limiter)
  • Path traversal: path.basename() + dangerous char removal + post-write resolved-path verification

Checklist

  • 30 MB client-side + server-side size limit
  • Multiple file selection
  • Files stored in {workspace}/uploads/
  • Electron behavior unchanged
  • WebUI sendbox + button → dropdown (Host Files / My Device)
  • Workspace toolbar upload entry for WebUI
  • File size toast notification
  • TypeScript, ESLint, unit tests all pass

Closes #1233

@audichuang
Copy link
Copy Markdown
Contributor Author

PNG圖片
CleanShot 2026-03-10 at 22 12 24@2x
CleanShot 2026-03-10 at 22 13 18@2x

workspace 档案显示
CleanShot 2026-03-10 at 22 13 36@2x

PDF
CleanShot 2026-03-10 at 22 13 57@2x

上传超过30MB档案大小提示
CleanShot 2026-03-10 at 22 14 27@2x

audichuang added a commit to audichuang/AionUi that referenced this pull request Mar 10, 2026
@kaizhou-lab
Copy link
Copy Markdown
Collaborator

我的装置,没有看到入口呀

@kaizhou-lab kaizhou-lab self-assigned this Mar 17, 2026
@audichuang audichuang force-pushed the feat/webui-file-upload-v2 branch from 9559df0 to 6bfb210 Compare March 17, 2026 14:20
@ringringlin
Copy link
Copy Markdown
Collaborator

@audichuang 感谢贡献 基本功能运行正常,请拉取主干最新代码避免后续冲突,即将合并
但是另外的问题是,在手机/移动设备上 当前的代码支持传 图片 以外的文件吗?
057c5e277fc9e3466c6c95c11f2d51ad_compress

…AI#1233)

- Add POST /api/upload endpoint with multer (30MB limit, path traversal protection)
- Platform-aware PasteService and FileService (Electron IPC vs WebUI HTTP)
- FileAttachButton component with dropdown (Host Files / My Device)
- Workspace toolbar upload button for WebUI
- File size toast notifications and upload loading state
- i18n for 6 languages (en/zh-CN/zh-TW/ja/ko/tr)
- Unit tests for resolveUploadWorkspace
@audichuang audichuang force-pushed the feat/webui-file-upload-v2 branch from 6bfb210 to 26caf6a Compare March 18, 2026 03:09
@audichuang
Copy link
Copy Markdown
Contributor Author

@ringringlin 感谢审核! 目前的实现不限制文件类型,在手机/移动设备上也可以上传图片以外的文件(PDF、文档、代码文件等),唯一的限制是单个文件大小不超过 30MB。关于拉取主干代码的部分,已经完成 rebase,目前是最新状态。

@ringringlin
Copy link
Copy Markdown
Collaborator

@肥勃 (audichuang)  audi友友,有个疑问,我刚才在测试的时候 我的手机好像无法上传除图片以外的文件 ,是因为我的手机浏览器权限问题嘛,如我刚才share的图片所示,只能upload image

Resolve bun.lock conflict by regenerating via bun install.
@piorpua piorpua merged commit 7b6063e into iOfficeAI:main Mar 18, 2026
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.

[Feature]: WebUI 移动端/远端文件上传

4 participants