export-download-debugging
它能做什么
这个工具可以帮你找出下载或导出文件失败的原因。它会在保存文件之前,先检查文件是否被正确生成,尤其是图片文件。
适用场景
- ✓当下载或导出看似成功,但文件最后是空的时。
- ✓当下载的图片无法打开或已经损坏时。
- ✓当你在浏览器或应用中使用“另存为”功能遇到问题时。
技能链接
https://github.com/nexu-io/open-design/blob/main/skills/export-download-debugging/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我导出的图片只有 0 KB,能帮我修复吗?”
每周 5 个新技能,1 分钟读完。
工作原理
它会先检查文件的数据是否正确生成。如果数据没有问题,就会改用更简单、更可靠的方法来保存文件,避开容易导致空文件的常见问题。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Export Download Debugging
Use this when an export or download appears to run but produces an empty, missing, or unusable file. It is tuned for browser previews, iframe capture, and Electron shells.
Core rule
Separate capture from save. Prove the export payload has non-zero bytes before debugging the destination path. A 0 KB file often means the native picker or host created the target file, then the write failed or was blocked.
Evidence
- Record the payload type, MIME type, byte length, object URL or data URL path, and thrown error name/message.
- Check browser console output and app logs around
showSaveFilePicker,createWritable,<a download>,URL.createObjectURL, and URL revocation. - In Electron, inspect the
will-downloadpath: filename, MIME, file extension, save dialog filters, cancellation, and final file size. - Confirm the actual downloaded file size on disk and whether it opens in a normal image viewer.
Fix order
- Prepare and validate the export payload first; disable Save until bytes are available.
- Prefer the simplest stable save channel for the host. If
showSaveFilePicker().createWritable()fails, is sandboxed, or creates empty files, route to<a download>or Electron's download manager instead. - Avoid opening a native picker before the payload is ready. This prevents the host from creating an empty destination file on later write failure.
- For PNG fallback, prefer a verified non-empty data URL when blob URLs, revocation timing, CSP, or iframe sandboxing are suspicious.
- In Electron, add explicit Save As filters for exported image extensions
(
.png,.jpg,.jpeg,.webp) so users can choose a real image target. - Keep the UI restrained: format selection, filename/path hint, clear pending and error states, and one primary save action.
Validation
- Add or update tests for non-empty payload preparation, fallback save behavior, file extension/MIME mapping, and UI disabled/error states.
- Run focused export tests, then
pnpm --filter @open-design/web typecheck. - If Electron download handling changed, also run
pnpm --filter @open-design/desktop typecheck. - Before landing, run
pnpm guard, inspect the staged diff for unrelated files, generated artifacts, and accidental secrets, then use the repository's PR quality-gate workflow if the fix is being prepared for review.
常见问题
为什么文件会变成空的?
这通常是因为系统已经在你的电脑上创建了文件,但在写入实际数据的过程中失败,或者在完成前被阻止了。
什么是 payload(载荷)?
payload 指你想导出或下载的信息和数据,比如图片的像素或文档的内容。
什么是 Blob/Data URLs?
这是在浏览器中直接表示数据(如图片)的方式,无需单独的文件。工具会检查它们是否正常工作。
详情
作者的原始描述
Diagnose and fix browser, preview, or Electron export/download failures, especially image export issues involving Save As, Blob/Data URLs, the File System Access API, createWritable failures, and 0 KB files.
repo: nexu-io/open-design
热度
- GitHub 星标
- 101k
- 排名
- #1150
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/15
评论
- …