Skip to content

Feature: docs +fetch should support --resolve-media to auto-download images/files #259

@liuhedev

Description

@liuhedev

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:

  1. During the fetch, identifies all <image>, <file>, and <whiteboard> placeholder tags
  2. Immediately downloads each media asset using the same auth context (while permission is still valid)
  3. Saves assets to a local directory (e.g., assets/<doc-name>/)
  4. Replaces placeholder tags with standard Markdown references (![](assets/...), [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 ./images

Workaround

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions