Skill: jpengcheng523-netizen/uploader (version 1.0.0)

--- name: uploader description: "Upload a local file to Astron Claw Bridge and return a public download URL." --- # uploader Upload a local file to Astron Claw Bridge Server and return a publicly accessible download URL. Supports images, audio, video, documents and other file types. ## When to Use ✅ **USE this skill when:** - When the user wants to obtain the file. - When the user needs a download URL for a local file (image, audio, video, document, etc.). - When the user wants to generate an external link for embedding in markdown or web pages. ## When NOT to Use ❌ **DON'T use this skill when:** - When the user only wants to read or view a local file without uploading. ## Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | file | string | Yes | Absolute or relative path to the local file to upload | | --session-id | string | No | Optional session ID for the upload | ## Commands ### Basic Call ```bash python3 scripts/upload_media.py '/path/to/file.png' ``` ### With Session ID ```bash python3 scripts/upload_media.py '/path/to/file.png' --session-id 'my-session' ``` ## Examples **"Help me upload this image and get a link."** ```bash python3 scripts/upload_media.py './screenshot.png' ``` **"Upload this PDF document."** ```bash python3 scripts/upload_media.py './report.pdf' ``` ## Response Script outputs upload result to stdout: ``` fileName: screenshot.png mimeType: image/png fileSize: 102400 sessionId: abc123 downloadUrl: http://.../<path>/<filename> ``` ## Notes - Host and token are auto-read from `/root/.openclaw/openclaw.json`, no need to pass at runtime - Requires `requests` package: `pip install requests`

path: scripts/upload_media.py
content: #!/usr/bin/env python3
"""
Upload a file to Astron Claw Bridge Server via POST /api/media/upload.
Host and token are auto-read from /root/.openclaw/openclaw.json.

Usage:
    python upload_media.py <file_path> [--session-id <sid>]
"""
import sys
import os
import json
import argparse
from urllib.parse import urlparse
import requests

CONFIG_PATH = "/root/.openclaw/openclaw.json"


def read_openclaw_config(config_path=CONFIG_PATH):
    try:
        with open(config_path, "r", encoding="utf-8") as f:
            config = json.load(f)

        bridge = config["plugins"]["entries"]["astron-claw"]["config"]["bridge"]
        host = urlparse(bridge["url"]).netloc
        [REDACTED_SECRET]"token"]
        return {"host": host, "token": token}
    except FileNotFoundError:
        print(f"Error: config not found at {config_path}")
    except (KeyError, TypeError):
        print("Error: bridge config missing in openclaw.json")
    except json.JSONDecodeError:
        print(f"Error: invalid JSON in {config_path}")
    return None


def upload_media(file_path: str, session_id: str = None) -> dict | None:
    config = read_openclaw_config()
    if not config:
        return None

    if not os.path.isfile(file_path):
        print(f"File not found: {file_path}")
        return None

    url = f"http://{config['host']}/api/media/upload"
    filename = os.path.basename(file_path)

    with open(file_path, "rb") as f:
        resp = requests.post(
            url,
            headers={"Authorization": f"Bearer {config['token']}"},
            files={"file": (filename, f)},
            data={"sessionId": session_id} if session_id else {},
        )

    if resp.status_code != 200:
        print(f"Upload failed ({resp.status_code}): {resp.text}")
        return None

    result = resp.json()
    print(f"fileName:    {result['fileName']}")
    print(f"mimeType:    {result['mimeType']}")
    print(f"fileSize:    {result['fileSize']}")
    print(f"sessionId:   {result['sessionId']}")
    print(f"downloadUrl: {result['downloadUrl']}")
    return result


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Upload a file to Astron Claw Bridge")
    parser.add_argument("file", help="Path to the file to upload")
    parser.add_argument("--session-id", help="Optional session ID", default=None)
    args = parser.parse_args()

    if not upload_media(args.file, args.session_id):
        sys.exit(1)


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)