-
Notifications
You must be signed in to change notification settings - Fork 392
Feature: docs +fetch should support --resolve-media to auto-download images/files #259
Description
Problem
When using docs +fetch to export a Lark document as Markdown, images and files are exported as placeholder tags:
<image token="DKblbz86oojD..." width="1833" height="2491"/>
<file token="WIKKbg01lonJ..." name="skills.zip"/>These placeholders cannot be rendered in any Markdown viewer. Users must manually call docs +media-download for each token to get the actual files.
Critical issue: When fetching documents from shared Wiki spaces, docs +fetch has read permission at fetch time, but docs +media-download called later often returns HTTP 403 Forbidden — the media download API requires separate permission that may not be available after the initial fetch.
Proposed Solution
Add a --resolve-media flag to docs +fetch that:
- During the fetch, identifies all
<image>,<file>, and<whiteboard>placeholder tags - Immediately downloads each media asset using the same auth context (while permission is still valid)
- Saves assets to a local directory (e.g.,
assets/<doc-name>/) - Replaces placeholder tags with standard Markdown references (
,[file](assets/...))
# Current behavior (placeholders only)
lark-cli docs +fetch --doc /wiki/TOKEN
# Proposed behavior (with media resolution)
lark-cli docs +fetch --doc /wiki/TOKEN --resolve-media
lark-cli docs +fetch --doc /wiki/TOKEN --resolve-media --media-dir ./imagesWorkaround
I wrote a Python script that does this post-hoc, but it fails with 403 on shared documents because the media download permission window has closed: https://gist.github.com/liuhedev
Environment
- lark-cli version: latest
- OS: macOS arm64
- Auth: user identity (feishu)