← Back to Skills Marketplace
mtafersit1-png

文件下载服务器

by mtafersit1-png · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ⚠ suspicious
262
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install file-download-server
Description
快速搭建临时文件下载服务器,支持HTTP下载、美观的下载页面、防火墙端口自动开放。适用于需要向用户发送文件但聊天工具不支持直接文件传输的场景。触发词:下载服务器、文件下载、发送文件、搭建下载链接
README (SKILL.md)

文件下载服务器 (File Download Server)

快速搭建临时 HTTP 文件下载服务器,解决文件传输问题。

功能特性

  • ✅ 一键启动 HTTP 服务器
  • ✅ 自动生成美观的下载页面
  • ✅ 自动开放防火墙端口
  • ✅ 支持大文件下载
  • ✅ 后台运行管理

快速开始

启动下载服务器

# 使用默认端口 4000
python3 {baseDir}/scripts/start_server.py /path/to/files

# 指定端口
python3 {baseDir}/scripts/start_server.py /path/to/files --port 8080

# 后台运行
python3 {baseDir}/scripts/start_server.py /path/to/files --daemon

生成下载页面

# 为单个文件生成下载页面
python3 {baseDir}/scripts/generate_index.py /path/to/file.pdf

# 为整个目录生成下载页面
python3 {baseDir}/scripts/generate_index.py /path/to/directory

开放防火墙端口

# 开放指定端口
python3 {baseDir}/scripts/open_port.py 4000

# 同时开放多个端口
python3 {baseDir}/scripts/open_port.py 4000 8080 9999

使用示例

示例 1: 发送论文 PDF

# 1. 确保文件存在
pdf_path = "/root/.openclaw/workspace/papers/casting-defect-detection.pdf"

# 2. 生成下载页面
from scripts.generate_index import generate_download_page
generate_download_page(pdf_path, title="论文下载", description="这是一篇关于铸件缺陷检测的论文")

# 3. 启动服务器
from scripts.start_server import start_download_server
server = start_download_server(
    directory="/root/.openclaw/workspace/papers",
    port=4000,
    daemon=True
)

# 4. 给用户发送下载链接
print("📥 下载链接: http://your-server-ip:4000/")

示例 2: 批量文件分享

# 为整个项目目录创建下载服务
python3 {baseDir}/scripts/start_server.py /path/to/project --port 8080 --daemon

# 用户可以访问 http://your-ip:8080/ 浏览和下载所有文件

脚本说明

scripts/start_server.py

启动文件下载服务器的主脚本。

参数:

  • directory: 要分享的文件目录路径
  • --port PORT: 服务器端口(默认: 4000)
  • --daemon: 后台运行
  • --bind ADDRESS: 绑定地址(默认: 0.0.0.0)

scripts/generate_index.py

生成美观的下载页面。

参数:

  • path: 文件或目录路径
  • --title TITLE: 页面标题
  • --description DESC: 页面描述
  • --output FILE: 输出 HTML 文件路径

scripts/open_port.py

开放防火墙端口。

参数:

  • ports: 要开放的端口列表(可多个)

下载页面特性

生成的 HTML 下载页面包含:

  • 🎨 现代化渐变设计
  • 📄 文件信息展示(标题、描述、大小)
  • ⬇️ 醒目的下载按钮
  • 📱 响应式布局,支持手机访问
  • 🔒 安全提示信息

服务管理

查看运行状态

# 查看 Python HTTP 服务器进程
ps aux | grep "python3 -m http.server"

停止服务器

# 查找并杀死进程
pkill -f "python3 -m http.server.*4000"

重启服务器

# 先停止,再启动
pkill -f "python3 -m http.server.*4000"
python3 {baseDir}/scripts/start_server.py /path/to/files --port 4000 --daemon

安全提示

⚠️ 重要安全注意事项:

  1. 临时使用: 此服务器仅用于临时文件分享,不要长期运行
  2. 端口安全: 使用后及时关闭防火墙端口
  3. 文件权限: 确保只分享必要的文件
  4. 访问控制: 生产环境建议添加认证机制
  5. 及时停止: 文件下载完成后立即停止服务器

故障排除

问题:无法访问下载链接

检查清单:

  1. 确认服务器正在运行: ps aux | grep http.server
  2. 确认防火墙端口已开放: iptables -L -n | grep 4000
  3. 确认云服务器安全组已放行该端口
  4. 检查文件路径是否正确

问题:下载速度慢

解决方案:

  • 使用更靠近用户的端口
  • 压缩大文件后再分享
  • 考虑使用专业的文件传输服务

问题:端口被占用

解决方案:

# 查找占用端口的进程
lsof -i :4000

# 杀死进程或换用其他端口
python3 {baseDir}/scripts/start_server.py /path/to/files --port 8080

高级用法

自定义下载页面

编辑 assets/download_template.html 来自定义页面样式。

支持的文件类型

下载页面会自动识别并适配:

  • 📄 PDF 文档
  • 📊 Excel/CSV 表格
  • 🖼️ 图片文件 (PNG, JPG, GIF)
  • 📦 压缩文件 (ZIP, RAR)
  • 🎬 视频文件 (MP4, AVI)
  • 📝 其他任意文件类型

多端口服务

可以同时启动多个服务器:

# 论文分享(端口 4000)
python3 {baseDir}/scripts/start_server.py /papers --port 4000 --daemon

# 数据分享(端口 8080)
python3 {baseDir}/scripts/start_server.py /data --port 8080 --daemon

参考资料

Usage Guidance
这项技能在功能和实现上自洽,但包含会修改防火墙(iptables)和控制进程(pkill)的命令 —— 这些需要管理员权限并会影响系统网络可达性。建议在安装/运行前: - 仅在受控、临时的环境(例如隔离的容器或临时云实例)中运行,避免在含有敏感数据的主机上分享整个根目录或重要目录。 - 确认启动时使用的目录只包含你愿意公开的文件;默认示例中使用绝对路径(/root/...)仅作演示。 - 准备以非 root 身份运行或在需要时手动执行防火墙命令;理解 iptables 操作需要 root。 - 注意 SKILL.md 提到的 assets/download_template.html 在包内未找到,若需要自定义页面请先准备该模板或直接编辑生成的 index.html。 - 不要将此技能用于长期对外暴露的生产环境;若需要长期共享,请增加认证/访问控制或使用专业传输服务。
Capability Analysis
Type: OpenClaw Skill Name: file-download-server Version: 1.1.0 The skill bundle provides functionality to start an unauthenticated HTTP server and automatically modify system firewall rules using `iptables` (`scripts/open_port.py`, `scripts/start_server.py`). While these actions are aligned with the stated purpose of temporary file sharing, they constitute high-risk behaviors that expose the host to network attacks and potential data leakage. No evidence of intentional malice, such as hardcoded backdoors or data exfiltration, was found, but the automated manipulation of system security settings and lack of access control warrant a suspicious classification. An example IP `81.70.47.140` is included in the documentation.
Capability Assessment
Purpose & Capability
技能名/描述(临时文件下载、生成下载页面、开放端口)与包含的脚本(generate_index.py、start_server.py、open_port.py)一致:脚本生成 index.html、启动 python -m http.server 并调用 iptables 开放端口,属于该功能所需的操作。
Instruction Scope
SKILL.md 和脚本的指令限定在启动文件服务器、生成 HTML 页面和修改本机防火墙规则。要注意:脚本会运行本地命令(iptables、pkill、ps、lsof),并建议访问/示例使用绝对路径(如 /root/...);这些操作在提供下载服务时合理,但会触及系统防火墙和进程控制,需谨慎(见用户指导)。此外文档提到 assets/download_template.html 但包中未见该文件,属于小的不一致。
Install Mechanism
无安装规范(instruction-only + 脚本已包含),不会从外部下载或在安装时执行远程代码,风险较低。
Credentials
技能不请求任何环境变量或外部凭据,也未声明访问其他服务的密钥。脚本仅使用本地文件系统与本机命令,所需权限与功能相称。
Persistence & Privilege
技能未设置 always:true,也不请求长期驻留权限。不过脚本尝试直接运行 iptables 命令来修改防火墙,这需要管理员/root 权限才能成功;如果在有高权限的环境中运行,脚本会修改系统防火墙和启动服务器进程,用户应确认运行上下文和权限边界。
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install file-download-server
  3. After installation, invoke the skill by name or use /file-download-server
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.1.0
更新:优化下载页面样式,参考其他龙虾机器人的方案,更简洁实用;添加文件上传时间显示、服务状态指示器
v1.0.0
初始版本:支持快速搭建临时文件下载服务器,美观的下载页面,自动防火墙端口管理
Metadata
Slug file-download-server
Version 1.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is 文件下载服务器?

快速搭建临时文件下载服务器,支持HTTP下载、美观的下载页面、防火墙端口自动开放。适用于需要向用户发送文件但聊天工具不支持直接文件传输的场景。触发词:下载服务器、文件下载、发送文件、搭建下载链接. It is an AI Agent Skill for Claude Code / OpenClaw, with 262 downloads so far.

How do I install 文件下载服务器?

Run "/install file-download-server" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 文件下载服务器 free?

Yes, 文件下载服务器 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 文件下载服务器 support?

文件下载服务器 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 文件下载服务器?

It is built and maintained by mtafersit1-png (@mtafersit1-png); the current version is v1.1.0.

💬 Comments