wecomcli-media
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese企业微信媒体文件
WeCom Media Files
执行任何命令前,必须先读取并完成wecom-cli技能的公共前置检查。wecomcli-shared
资源型 skill,负责基于 下载媒体文件到本地,以及把本地文件上传为 。是其他技能(微盘、邮件等)处理 相关操作的基础依赖: 会产出新的 ,但本 skill 不负责搜索/发现其他业务场景中已存在的 (如邮件附件、微盘文件的 由对应业务技能产出),也不解析文件内容。
media_idmedia_idmedia_iduploadmedia_idmedia_idmedia_idBefore executing anycommand, you must first read and complete the common pre-checks of thewecom-cliskill.wecomcli-shared
A resource-type skill responsible for downloading media files to local based on and uploading local files to generate . It is a basic dependency for other skills (such as WeCom Disk, Email, etc.) to handle -related operations: will generate a new , but this skill does not search/discover existing in other business scenarios (e.g., of email attachments or WeCom Disk files are generated by corresponding business skills), nor does it parse file content.
media_idmedia_idmedia_iduploadmedia_idmedia_idmedia_id适用范围
Scope of Application
适用
Applicable Scenarios
- 根据其他技能或用户提供的 下载媒体文件到本地
media_id - 上传本地文件(本地路径已知)获取 ,供其他技能后续使用(如微盘上传素材)
media_id
- Download media files to local based on provided by other skills or users
media_id - Upload local files (with known local path) to obtain for subsequent use by other skills (such as uploading materials to WeCom Disk)
media_id
不适用
Inapplicable Scenarios
- 解析/识别文件内容(正文提取、OCR、看图问答、PDF/Word/Excel 解析等) → 本 skill 只负责把文件下载到本地拿 ,如需查看内容请直接通过
file_path读取该本地文件file_path - 搜索/发现其他业务场景中已存在的 (如邮件附件、微盘文件列表/搜索等) → 由对应业务技能负责产出并返回
media_id,本 skill 只接收已有的media_id做下载;本地文件转media_id的场景仍走本 skill 的media_idupload - 编造或猜测 / 本地文件路径 → 两者必须来自其他技能返回或用户明确提供,禁止自行构造
media_id
- Parse/identify file content (text extraction, OCR, image Q&A, PDF/Word/Excel parsing, etc.) → This skill only downloads files to local to get . If you need to view the content, please directly read the local file via
file_pathfile_path - Search/discover existing in other business scenarios (such as email attachments, WeCom Disk file list/search, etc.) → Corresponding business skills are responsible for generating and returning
media_id. This skill only accepts existingmedia_idfor download; for converting local files tomedia_id, still use themedia_idfunction of this skillupload - Fabricate or guess / local file path → Both must come from other skills' returns or be clearly provided by users. Fabrication is prohibited
media_id
接口详述
Interface Details
下载媒体文件
Download Media File
根据 下载媒体文件到本地,返回本地文件路径。
media_id命令
bash
wecom-cli media download --json '{"media_id": "MEDIA_ID"}'入参
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| string | 是 | 文件的 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
| string | 下载成功后的本地文件路径 |
使用规则
- 下载完成后如需查看文件内容,直接通过 读取该本地文件。
file_path - 下载失败时返回错误码和错误信息。
- 必须是真正的 media_id,不接受任何形式的 URL:若拿到的是一个链接(如
media_id、正文里的图片/附件链接),不要把这个 URL 当作attach_url传入本接口,会直接报错。尤其是命中media_id特征的防泄漏加密链接,属于加密的、与用户身份绑定的资源,本接口无法下载或解密,应直接告知用户该文件受防泄漏策略保护,引导其点击链接、在企业微信客户端内打开查看/保存,不要尝试用本接口或其他手段绕过。work.weixin.qq.com/filepreview/security/
Download media files to local based on and return the local file path.
media_idCommand
bash
wecom-cli media download --json '{"media_id": "MEDIA_ID"}'Input Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | |
Return
| Field | Type | Description |
|---|---|---|
| string | Local file path after successful download |
Usage Rules
- If you need to view the file content after download, directly read the local file via .
file_path - Return error code and error message when download fails.
- must be a real media_id, no URLs of any form are accepted: If you get a link (such as
media_id, image/attachment link in the text), do not pass this URL asattach_urlto this interface, as it will directly report an error. Especially for anti-leakage encrypted links with the featuremedia_id, which are encrypted resources bound to user identity, this interface cannot download or decrypt them. You should directly inform the user that the file is protected by anti-leakage policies, guide them to click the link and open/view/save it in the WeCom client, and do not attempt to bypass it using this interface or other means.work.weixin.qq.com/filepreview/security/
上传媒体文件
Upload Media File
将本地文件上传,获取 。
media_id命令
bash
wecom-cli media upload --json '{"file_path": "/tmp/example.pdf"}'入参
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| string | 是 | 需要上传的文件的本地路径 |
返回
| 字段 | 类型 | 说明 |
|---|---|---|
| string | 媒体类型: |
| string | 上传后的 |
| string | 创建时间,格式: |
Upload local files to obtain .
media_idCommand
bash
wecom-cli media upload --json '{"file_path": "/tmp/example.pdf"}'Input Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Local path of the file to be uploaded |
Return
| Field | Type | Description |
|---|---|---|
| string | Media type: |
| string | |
| string | Creation time, format: |
关键约束
Key Constraints
- /
media_id不得编造:file_path必须来自上传结果、其他技能返回或用户明确提供;media_id必须是真实存在的本地路径。两者都没有时用自然语言追问,禁止靠猜测凑一个。file_path - 不做内容解析:本 skill 只负责文件的下载落地与上传,拿到
download后如需查看内容,直接通过file_path读取,不在本 skill 职责范围内。file_path - 内部 ID 不外露:仅用于后续接口调用,禁止直接展示给用户;下载后的本地
media_id同样不展示给用户。file_path - CLI 报错原样转达:命令返回明确错误码时如实告知用户并给替代建议,禁止用 curl / python 等通用手段绕过 CLI 强行完成。
- /
media_idcannot be fabricated:file_pathmust come from upload results, other skills' returns or be clearly provided by users;media_idmust be a real existing local path. If neither is available, ask the user clearly in natural language, do not guess.file_path - No content parsing: This skill only handles file download and upload. After obtaining via
file_path, if you need to view the content, directly read it viadownload, which is not within the scope of this skill.file_path - Internal ID not exposed: is only used for subsequent interface calls, and it is prohibited to directly display it to users; the local
media_idafter download is also not displayed to users.file_path - Convey CLI errors as is: When the command returns a clear error code, inform the user truthfully and provide alternative suggestions. Do not use general methods such as curl / python to bypass the CLI to force completion.
跨技能依赖
Cross-Skill Dependencies
| 依赖场景 | 说明 |
|---|---|
| 邮件附件/内嵌图片的 |
| 上传文件到微盘时若已有 |
参数缺失 / 意图不明确时,用自然语言追问让用户明确,不要瞎猜。
| Dependency Scenario | Description |
|---|---|
| For |
| When uploading files to WeCom Disk, if |
When parameters are missing / intent is unclear, ask the user clearly in natural language, do not guess.