SuperAPI AI Directory

wecomcli-media

Office & productivity

View repository

Updated 10-16 09:20

About this skill

wecom-cli is a tool provided by the plugin, not a terminal command: all operations are completed by calling this tool, and parameters should be passed using args . It is prohibited to use it via command-line methods such as exec / shell / terminal.

⚠️ Prerequisite: Before calling wecom-cli for the first time, prerequisite checks must be performed according to the wecomcli-preflight skill to ensure the tool has been added to the allowlist.

WeCom media files

Resource-type skill, responsible for downloading media files to the local machine based on media_id , and uploading local files as media_id. It is a basic dependency for other skills (WeDrive, email, etc.) handling media_id -related operations:upload will produce a new media_id, but this skill is not responsible for searching/discovering media_idthat already exist in other business scenarios (such as email attachments, WeDrive files. The media_id is produced by the corresponding business skill), nor does it parse file contents.

Scope of application

Applicable

  • Download media files to the local machine based on the media_id provided by other skills or the user
  • Upload local files (local path known) to obtain media_id, for subsequent use by other skills (such as uploading materials to WeDrive)

Not applicable

  • Parsing/recognizing file contents (body text extraction, OCR, image Q&A, PDF/Word/Excel parsing, etc.) → This skill is only responsible for downloading the file to the local machine to obtain file_path. If you need to view the content, please directly read the local file through file_path Read this local file
  • Searching/discovering media_idthat already exist in other business scenarios (such as email attachments, WeDrive file lists/searches, etc.) → The corresponding business skill is responsible for producing and returning media_id. This skill only receives existing media_id for downloading; the scenario of converting a local file tomedia_id still uses this skill's upload
  • Fabricating or guessing media_id / local file paths → Both must come from what is returned by other skills or explicitly provided by the user; constructing them yourself is prohibited

Interface details

Download media file

Based on media_id , download the media file to the local machine and return the local file path.

How to call

Use the wecom-cli tool to call in the following format

wecom-cli media download --json '{"media_id": "MEDIA_ID"}'

Input parameters

Field Type Required Description
media_id string Yes The file's media_id, obtained after uploading the file, or returned by other skills (email attachments/embedded images, etc.)

Return

Field Type Description
file_path string Local file path after successful download

Usage rules

  • After downloading, if you need to view the file content, directly read the local file through file_path .
  • On download failure, an error code and error message are returned.
  • media_id must be a real media_id; URLs in any form are not accepted: If what you get is a link (such as attach_url, image/attachment links in the body),do notTreat this URL as media_id and pass it to this interface; it will directly return an error. This is especially true for anti-leak encrypted links matching the work.weixin.qq.com/filepreview/security/ feature, which are encrypted resources bound to user identity; this interfacecannot download or decrypt them, and you should directly tell the user that the file is protected by the anti-leak policy, guide them to click the link and open it in the WeCom client to view/save, and do not attempt to bypass it with this interface or other means.

Upload media file

Upload a local file to obtain media_id。

Usage

Use the wecom-cli tool to call it in the following format

wecom-cli media upload --json '{"file_path": "/tmp/example.pdf"}'

Input parameters

Field Type Required Description
file_path string Yes Local path of the file to be uploaded

Return

Field Type Description
type string Media type:image(image)/voice(voice)/video(video)/file(file)
media_id string After upload, the media_id, for subsequent use by other skills (such as WeDriveupload 's file_content_media)
created_at string Creation time, format:YYYY-MM-DD HH:mm:ss

Key constraints

  • media_id / file_path must not be fabricated:media_id must come from the upload result, another skill's return, or be explicitly provided by the user;file_path must be a real existing local path. When neither is available, ask a follow-up question in natural language; do not guess and make one up.
  • No content parsing: This skill is only responsible for downloading files locally and uploading them;download after obtaining file_path if its content needs to be viewed, read it directly via file_path , which is outside the scope of this skill.
  • Internal IDs are not exposed:media_id is only used for subsequent interface calls and must not be shown directly to users; the downloaded local file_path is likewise not shown to users.
  • Relay CLI errors verbatim: When the command returns an explicit error code, truthfully inform the user and provide alternative suggestions; do not use general-purpose means such as curl / python to bypass the CLI and force completion.

Cross-skill dependencies

Dependency scenario Description
wecomcli-email Email attachment/inline image media_id, use this skill's download to download it locally and then read it via file_path read
wecomcli-disk When uploading a file to WeDrive, if there is already a media_id, directly use it as disk files upload 's file_content_media use it without going through this skill again; if there is only a local path and it needs to be converted to media_id, you can use this skill's upload

When parameters are missing / the intent is unclear, use natural language follow-up questions to get the user to clarify; do not guess blindly.