ai_member_xiaobian/.agents/skills/lark-okr/references/lark-okr-image-upload.md
2026-05-15 10:57:05 +08:00

3.4 KiB
Raw Permalink Blame History

okr +upload-image

前置条件: 先阅读 lark-shared/SKILL.md 了解认证、全局参数和安全规则。

上传本地图片,用于 OKR 进展记录的富文本内容。

推荐命令

# 上传图片用于目标的进展记录
lark-cli okr +upload-image \
  --file ./progress_screenshot.png \
  --target-id 1234567890123456789 \
  --target-type objective

# 上传图片用于关键结果的进展记录
lark-cli okr +upload-image \
  --file ./chart.jpg \
  --target-id 9876543210987654321 \
  --target-type key_result

参数

参数 必填 默认值 说明
--file 本地图片路径。必须使用相对路径(如 ./photo.png)。
--target-id 目标 ID 或关键结果 IDint64 类型,正整数)
--target-type 目标类型:objective | key_result
--dry-run 预览 API 调用而不实际执行。

工作流程

  1. 使用 +cycle-list+cycle-detail 获取目标或关键结果的 ID。
  2. 准备本地图片文件,确保格式受支持。
  3. 执行 lark-cli okr +upload-image --file ./image.png --target-id "..." --target-type objective
  4. 获取返回的 file_token,用于构建 ContentBlock 中的图片内容。

输出

返回 JSON

{
  "file_token": "example-file-token",
  "url": "https://example.larksuite.com/download?file_token=example-file-token",
  "file_name": "screenshot.png",
  "size": 102400
}

其中:

  • file_token — 用于在 ContentBlock 的 ContentGallery 中引用图片
  • url — 图片的访问 URL
  • file_name — 上传的文件名
  • size — 文件大小(字节)

在进展记录中使用上传的图片

上传图片后,将返回的 file_token 用于构建 ContentBlock 的图库块:

{
  "blocks": [
    {
      "block_element_type": "paragraph",
      "paragraph": {
        "elements": [
          {
            "paragraph_element_type": "textRun",
            "text_run": {
              "text": "本周进展截图:"
            }
          }
        ]
      }
    },
    {
      "block_element_type": "gallery",
      "gallery": {
        "images": [
          {
            "file_token": "example-file-token",
            "width": 800,
            "height": 600
          }
        ]
      }
    }
  ]
}

然后在创建或更新进展记录时使用此 ContentBlock

lark-cli okr +progress-create \
  --content @content_with_image.json \
  --target-id 1234567890123456789 \
  --target-type objective

安全限制

  • --file 参数必须使用相对路径(如 ./photo.pngimages/photo.png),不支持绝对路径
  • 图片文件必须存在于当前工作目录或其子目录中
  • 不支持符号链接指向目录外的文件

参考