Manage materials (images, files, etc.) in Feishu cloud documents, including upload and download operations.
Usage
/feishu-media upload <file> --parent-node <doc_id> # 上传素材
/feishu-media download <file_token> [--output path] # 下载素材
CLI Command Details
1. Upload Material
Upload a local file to Feishu cloud space, for use as an image or attachment in a document.
# 上传图片到文档
feishu-cli media upload ./image.png --parent-type docx_image --parent-node <document_id>
# 上传文件到文档
feishu-cli media upload ./attachment.pdf --parent-type docx_file --parent-node <document_id>
# 指定文件名
feishu-cli media upload ./photo.jpg --parent-type docx_image --parent-node <doc_id> --name "封面图"
# JSON 格式输出
feishu-cli media upload ./image.png --parent-type docx_image --parent-node <doc_id> --output json
Parameter Description:
| Parameter | Description | Required | Example |
|---|---|---|---|
file |
Local file path | Yes | ./image.png |
--parent-type |
Parent type | Yes | docx_image |
--parent-node |
Parent node Token | Yes | Document ID |
--name |
Custom file name | No | 封面图 |
--output |
Output format | No | json |
parent-type types:
| Value | Description |
|---|---|
docx_image |
New version document image (recommended, default value) |
docx_file |
New version document file |
doc_image |
Old version document image (not recommended, will fail in DocX documents) |
doc_file |
Old version document file |
sheet_image |
Image in a table |
comment_image |
Image in a comment |
Output Example:
素材上传成功!
文件 Token: boxcnAbCdEfGhIjKlMnOpQrSt
文件名: image.png
父节点: doccnXxx
JSON Output:
{
"file_token": "boxcnAbCdEfGhIjKlMnOpQrSt",
"file_name": "image.png",
"parent_node": "doccnXxx"
}
2. Download Material
Download a file or image from Feishu cloud space.
# 下载到当前目录(使用原文件名)
feishu-cli media download <file_token>
# 下载到指定路径
feishu-cli media download <file_token> --output ./downloads/image.png
# 下载到指定目录(自动命名)
feishu-cli media download <file_token> --output ./downloads/
Parameter Description:
| Parameter | Description | Required | Default value |
|---|---|---|---|
file_token |
File Token | Yes | - |
--output, -o |
Output path | No | Current directory |
Output Example:
已下载到 ./downloads/image.png
文件大小: 256 KB
文件类型: image/png
Typical Workflows
Upload an image to a document
# 1. 上传图片
feishu-cli media upload ./diagram.png --parent-type docx_image --parent-node doccnXxx --output json
# 返回: {"file_token": "boxcnYyy"}
# 2. 在 Markdown 中引用(导入时自动处理)
# 
Batch download document images
# 1. 导出文档并下载图片
feishu-cli doc export doccnXxx -o doc.md --download-images --assets-dir ./images
# 或手动下载
feishu-cli media download boxcnToken1 -o ./images/
feishu-cli media download boxcnToken2 -o ./images/
Migrate document images
# 1. 从源文档下载图片
feishu-cli media download <old_token> -o /tmp/img.png
# 2. 上传到新文档
feishu-cli media upload /tmp/img.png --parent-type docx_image --parent-node <new_doc_id>
Supported File Formats
Images
- PNG, JPG, JPEG, GIF, BMP, SVG, WEBP
Files
- PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX
- ZIP, RAR, 7Z
- TXT, MD, CSV
- Other common formats
File Size Limits
| Type | Size limit |
|---|---|
| Images | 20 MB |
| Files | 512 MB |
Permission Requirements
drive:drive:readonly- Download filesdrive:drive- Upload files
Notes
- Token retrieval: Image Tokens can be extracted from the Markdown exported from a document
- Temporary links: Image links obtained via the API are time-limited (usually 24 hours)
- Batch operations: It is recommended to use
doc export --download-imagesto batch download document images - Format conversion: Feishu may perform format conversion and compression on uploaded images
- Default value change (v1.4.1):
--parent-typeThe default value has been changed fromdoc_imagetodocx_image, the old value will cause upload failures in DocX documents