惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

🕵️‍♂️匿名运维栈

Uv 完全指南 - 🕵️‍♂️匿名运维栈 Python typing类型注解完全指南 - 🕵️‍♂️匿名运维栈 2025:大语言模型(LLM)之年 - 🕵️‍♂️匿名运维栈 AI 代码指南 [转载] - 🕵️‍♂️匿名运维栈 Docker构建多架构镜像 - 🕵️‍♂️匿名运维栈 DNS 域名解析工具 - 🕵️‍♂️匿名运维栈 Ubuntu DNS解析失败排查记录:EasyConnect VPN劫持问题完全解析 - 🕵️‍♂️匿名运维栈 高效休息法:学习效率提升的科学指南 - 🕵️‍♂️匿名运维栈 Claude Code 子代理(Subagents)完全学习指南 - 🕵️‍♂️匿名运维栈
Lsky Pro + Typora 图床搭建
nwnusun · 2026-01-06 · via 🕵️‍♂️匿名运维栈

共计 1428 个字符,预计需要花费 4 分钟才能阅读完成。

采用的宝塔 docker 方式部署,登录后可以看到,该服务有上传图片接口, 后续的上传代码参照这块。

Lsky Pro + Typora 图床搭建
#!/usr/bin/env python3
import os
import sys
import requests
import json

# Lsky Pro 配置
LSKY_PRO_URL = "https://oss.nwnusun.cn"  # 替换为你的 Lsky Pro 域名
LSKY_API_TOKEN = "Bearer 1|327xxx"      # 替换为你的 API Token
UPLOAD_FOLDER_ID = 1  # 可选:上传到指定相册 ID

def upload_image_to_lsky(image_path):
    """上传图片到 Lsky Pro"""
    url = f"{LSKY_PRO_URL}/api/v1/upload"
    headers = {
        "Authorization": LSKY_API_TOKEN,
        "Accept": "application/json",
    }
    
    # 从路径获取文件名
    filename = os.path.basename(image_path)
    
    # 根据文件扩展名确定 MIME 类型
    mime_mapping = {
        ".png": 'image/png', 
        '.gif': 'image/gif', 
        '.jpg': 'image/jpeg', 
        '.jpeg': 'image/jpeg'
    }
    
    file_ext = os.path.splitext(image_path)[1].lower()
    mime_type = mime_mapping.get(file_ext, 'image/png')
    
    files = {"file": (filename, open(image_path, "rb"), mime_type)
    }
    
    data = {}
    if UPLOAD_FOLDER_ID:
        data["strategy_id"] = UPLOAD_FOLDER_ID
    
    try:
        response = requests.post(url, headers=headers, files=files, data=data)
        response.raise_for_status()
        result = response.json()
        
        if result.get("status"):
            # 只返回图片 URL 而不是完整的 Markdown 格式
            image_url = result["data"]["links"]["url"]
            return image_url
        else:
            return f"Error: {result.get('message','Unknown error')}"
    except Exception as e:
        return f"API Request Error: {str(e)}"

def main():
    # 检查是否提供了图片路径作为参数
    if len(sys.argv) < 2:
        print("用法: python typora_lsky_uploader.py < 图片路径 1 > [ 图片路径 2] ...")
        return
    
    # 上传命令行参数中的每个图片
    for img_path in sys.argv[1:]:
        if not os.path.exists(img_path):
            print(f"找不到文件: {img_path}")
            continue
            
        result = upload_image_to_lsky(img_path)
        print(result)

if __name__ == "__main__":
    main()
Lsky Pro + Typora 图床搭建