file-upload

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

File upload

文件上传

Publish one local file through the configured file host and return a URL the human can open. Public links serve from the host's public base URL without auth; the link for a key never changes.
通过配置的文件托管服务发布一个本地文件,并返回一个可供用户打开的URL。公共链接从托管服务的公共基础URL提供,无需身份验证;每个密钥对应的链接永久不变。

Requires

必要条件

FILE_HOST_URL
(the upload API endpoint) and
FILE_HOST_TOKEN
. The script loads them from
~/.agents/.env
when that file exists; already-set environment variables work too (on a cloud VM they come from the Cursor dashboard secrets). If both sources are missing, do not invent a service and do not use 1Password. Fall back to a local artifact and say so.
FILE_HOST_URL
(上传API端点)和
FILE_HOST_TOKEN
。当
~/.agents/.env
文件存在时,脚本会从中加载这两个变量;已设置的环境变量也可生效(在云虚拟机上,它们来自Cursor仪表板的密钥)。如果两个来源都缺失,请勿自行创建服务,也不要使用1Password。请回退到本地产物并告知用户。

Steps

步骤

  1. Confirm the file exists on this machine.
  2. Run the script that sits next to this SKILL.md (invoke via
    sh
    , the exec bit may be missing on a fresh copy):
bash
sh <path-to-this-skill>/scripts/upload.sh /path/to/file
  1. Key choice: by default the key is derived from the filename and stays readable (generated collisions get
    -2
    ,
    -3
    , …). Add
    --slug NAME
    for an exact key (fails with 409 if taken) or
    --random
    for a UUID key when the link should not be guessable.
  2. Treat stdout as the public URL. If the script exits non-zero, stop and report stderr.
  3. Never claim a public URL for a
    file://
    or
    artifacts/
    path.
  1. 确认文件存在于本地机器上。
  2. 运行与本SKILL.md同级的脚本(通过
    sh
    调用,新副本可能缺少执行权限):
bash
sh <path-to-this-skill>/scripts/upload.sh /path/to/file
  1. 密钥选择:默认情况下,密钥由文件名生成且保持可读(若产生冲突则追加
    -2
    -3
    ……)。若需要指定确切密钥,添加
    --slug NAME
    (若已被占用则返回409错误);若希望链接不可被猜测,添加
    --random
    以生成UUID密钥。
  2. 将标准输出视为公共URL。如果脚本非零退出,停止操作并报告标准错误信息。
  3. 切勿为
    file://
    artifacts/
    路径声称是公共URL。

Replace or delete

替换或删除

KEY is the last segment of the public URL. An update swaps the content behind the same link — no history. Delete is permanent and idempotent.
bash
sh <path-to-this-skill>/scripts/upload.sh --update KEY /path/to/file
sh <path-to-this-skill>/scripts/upload.sh --delete KEY
KEY是公共URL的最后一段。更新操作会替换同一链接后的内容——不保留历史记录。删除操作是永久性的且幂等。
bash
sh <path-to-this-skill>/scripts/upload.sh --update KEY /path/to/file
sh <path-to-this-skill>/scripts/upload.sh --delete KEY

Using the URL

URL的使用

  • PR or chat: paste the URL. For video, a short sentence plus the link is enough.
  • Optional GIF preview with ffmpeg only when the user asked for a preview image.
  • PR或聊天:粘贴URL。对于视频,只需简短说明加链接即可。
  • 仅当用户要求预览图片时,可使用ffmpeg生成可选的GIF预览。

Local fallback

本地回退方案

Without a host, the script copies to
~/.agents/artifacts/
(gitignored, created if missing) and prints a
file://
path. On a Mac with a display you may
open
that path if the user wants to see it. On a headless machine or cloud VM, just return the path.
若没有托管服务,脚本会将文件复制到
~/.agents/artifacts/
(已被git忽略,若不存在则自动创建)并打印
file://
路径。在带显示器的Mac上,如果用户想要查看,你可以
open
该路径。在无头机器或云虚拟机上,只需返回路径即可。