Clawdbot ToolsDocumentedScanned
feishu-file-fetch
Implements a Clawdbot extension tool that downloads Feishu files by message_id and file_key, streams to disk.
Share:
Installation
npx clawhub@latest install feishu-file-fetchView the full skill documentation and source below.
Documentation
feishu_file_fetch
Quick start
Create or update the reference implementation at scripts/feishu_file_fetch.py. It should:
{ message_id, file_key, type="file", outdir="/root/clawd/uploads", max_bytes=104857600 }{ ok, path, filename, bytes, sha256, error? }FEISHU_APP_ID / FEISHU_APP_SECRET to fetch and cache tenant_access_token (refresh 2 minutes before expiry).GET with Authorization: Bearer .
5. Stream to outdir/yyyyMMdd/, parse filename from Content-Disposition, fallback to file_key.bin.
6. Compute sha256 while streaming; enforce max_bytes strictly (terminate and delete temp file if exceeded).
7. Prevent path traversal by ensuring final path stays within outdir.
8. Never log tokens or secrets.
## Runtime notes
- Use only stdlib to avoid dependency installs.
- If Content-Length exceeds max_bytes, fail early.
- Use a temp file in the target directory and os.replace` on success.Example usage
echo '{"message_id":"om_xxx","file_key":"file_xxx"}' | python scripts/feishu_file_fetch.py
Additional resources
- For API details and error handling notes, see reference.md