feishu-upload-image
Upload images to Feishu/Lark. Returns image_key for use in messages.
它会碰到什么
扫了多少3 个文本文件,10 KB
它会碰到什么读凭据联网读文件执行命令
命中总数10 处
命中统计严重 0 · 高 2 · 中 4 · 低 1
逐条看命中(2 条严重或高危)
- 高
scripts/upload_image.py:117cred-envreadapp_id = os.environ.get("FEISHU_APP_ID") - 高
scripts/upload_image.py:118cred-envreadapp_secret = os.environ.get("FEISHU_APP_SECRET")
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Feishu Upload Image
Upload images to Feishu/Lark and get the image_key for use in messages.
Usage
Upload from Local File
python3 ./scripts/upload_image.py /path/to/image.jpg
Upload via HTTP
python3 ./scripts/upload_image.py --type message --image-type message https://example.com/image.jpg
Upload from Base64
python3 ./scripts/upload_image.py --base64 "iVBORw0KGgoAAAANS..."
Options
| Option | Description | Default |
|--------|-------------|---------|
| --type message|avatar | Image usage type | message |
| --image-type message|avatar | Same as --type | message |
Limits
- Max file size: 10MB
- Supported formats: JPEG, PNG, WEBP, GIF, TIFF, BMP, ICO
- GIF resolution ≤ 2000×2000
- Other formats ≤ 12000×12000
Response
Returns image_key which can be used in Feishu messages:
{
"code": 0,
"data": {
"image_key": "img_v2_xxx"
}
}
发送图片消息指南
获取必要信息
- 飞书访问令牌 (tenant_access_token 或 app_access_token)
- 接收者ID (open_id, user_id, chat_id, 或 email)
发送图片消息API
方式1:直接发送图片消息
curl -X POST https://open.feishu.cn/open-apis/im/v1/messages \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"receive_id": "{chat_id}",
"msg_type": "image",
"content": "{\"image_key\":\"{image_key}\"}"
}'
方式2:在富文本中嵌入图片
curl -X POST https://open.feishu.cn/open-apis/im/v1/messages \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"receive_id": "{chat_id}",
"msg_type": "post",
"content": "{\"post\":{\"zh_cn\":{\"title\":\"图片消息\",\"content\":[[{\"tag\":\"img\",\"image_key\":\"{image_key}\"}]]}}}"
}'
获取群聊chat_id
- 在飞书中打开群聊,查看URL中的chat_id
- 或者通过API查询群聊列表:
curl -X GET https://open.feishu.cn/open-apis/im/v1/chats \
-H "Authorization: Bearer {access_token}"
实践经验
- 上传图片后获得
image_key,有效期通常为7天 - 使用前需确保有正确的访问令牌权限
- 发送消息需要
im:message:send_as_bot权限 - 建议先上传图片,再发送消息,两步操作分离
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。