📥 Large File Downloader
When to Use
Use this skill when downloading files from HTTP/HTTPS URLs, especially large files (>100MB).
Typical scenarios:
- - Downloading software installers (DMG, EXE, ZIP)
- Downloading large datasets
- Downloading video/audio files
- Downloading documents/PDFs
- Any file download from URL
Trigger keywords:
- - "download this file"
- "save this DMG"
- "download from this URL"
- "get this file"
- "帮我下载 xxx" (Chinese)
Core Principles
⚠️ Must-Follow Best Practices
- 1. Always use background execution - Never run large downloads synchronously
- Always set timeout - Configure reasonable timeout based on file size
- Always support resume - Use
curl -C - for resumable downloads - Always show progress - Use
--progress-bar flag - Always verify results - Check file size after download completes
Standard Process
Step 1: Start Download (Background Mode)
CODEBLOCK0
Parameter explanation:
- -
-L - Follow redirects - INLINECODE3 - Resume partial download
- INLINECODE4 - Show progress bar
- INLINECODE5 - Output file path
- INLINECODE6 - Critical! Run in background to avoid timeout
- INLINECODE7 - 10 minutes timeout (adjust based on file size)
Step 2: Monitor Progress
CODEBLOCK1
Poll periodically to check download progress until completion.
Step 3: Verify Result
CODEBLOCK2
Check:
- - File exists
- File size is reasonable
- File is complete (compare MD5/SHA if available)
Complete Examples
Example 1: Download DMG File (215MB)
User: "Download https://github.com/example/app/releases/download/v1.0/app.dmg"
Agent action:
CODEBLOCK3
Returns: INLINECODE8
Then poll periodically:
CODEBLOCK4
After download completes, verify:
CODEBLOCK5
Example 2: Download Small File (<50MB)
For small files, simplified handling is acceptable:
CODEBLOCK6
Small files can run synchronously, but still set timeout.
Timeout Reference
| File Size | Recommended Timeout |
|---|
| < 50MB | 120 seconds (2 min) |
| 50-200MB |
300 seconds (5 min) |
| 200-500MB | 600 seconds (10 min) |
| 500MB-1GB | 1200 seconds (20 min) |
| > 1GB | 1800 seconds (30 min) or more |
Error Handling
Common Errors & Solutions
1. Download interrupted
CODEBLOCK7
2. Permission denied
CODEBLOCK8
3. Redirect failed
CODEBLOCK9
4. Network timeout
# Increase timeout or use --retry
curl -L --retry 3 --connect-timeout 30 -o file.zip <URL>
Advanced Options
Multi-threaded Download (aria2)
If aria2 is available, use multi-threading for faster downloads:
CODEBLOCK11
Full Flow with Progress Monitoring
CODEBLOCK12
Security Considerations
- 1. Download from trusted sources only - Verify URL origin
- Check file type - Use
file command to verify - Scan for viruses - If needed, scan after download
- Don't overwrite important files - Check if destination exists
Related Skills
- -
feishu-send-file - Send downloaded file to Feishu - INLINECODE11 - Read downloaded file content
- INLINECODE12 - Extract frames if video file
Troubleshooting
If download fails, follow these steps:
- 1. Check network connectivity
CODEBLOCK13
- 2. Check disk space
CODEBLOCK14
- 3. View detailed error
CODEBLOCK15
- 4. Try alternative tool
wget --continue <URL>
Remember: Always use background=true for large file downloads! 🎯
📥 大文件下载器
使用场景
当需要从 HTTP/HTTPS 网址下载文件时,尤其是大文件(>100MB),使用此技能。
典型场景:
- - 下载软件安装包(DMG、EXE、ZIP)
- 下载大型数据集
- 下载视频/音频文件
- 下载文档/PDF
- 从网址下载任何文件
触发关键词:
- - 下载这个文件
- 保存这个DMG
- 从这个网址下载
- 获取这个文件
- 帮我下载 xxx
核心原则
⚠️ 必须遵循的最佳实践
- 1. 始终使用后台执行 - 切勿同步运行大型下载
- 始终设置超时 - 根据文件大小配置合理的超时时间
- 始终支持断点续传 - 使用 curl -C - 实现可续传下载
- 始终显示进度 - 使用 --progress-bar 标志
- 始终验证结果 - 下载完成后检查文件大小
标准流程
步骤 1:开始下载(后台模式)
bash
exec(
command=curl -L -C - --progress-bar -o <目标路径> <网址>,
background=true,
timeout=600
)
参数说明:
- - -L - 跟随重定向
- -C - - 续传部分下载
- --progress-bar - 显示进度条
- -o - 输出文件路径
- background=true - 关键! 在后台运行以避免超时
- timeout=600 - 10分钟超时(根据文件大小调整)
步骤 2:监控进度
bash
process(action=poll, sessionId=<会话ID>)
定期轮询以检查下载进度,直到完成。
步骤 3:验证结果
bash
exec(command=ls -lh <文件路径>)
检查:
- - 文件是否存在
- 文件大小是否合理
- 文件是否完整(如有MD5/SHA则进行比较)
完整示例
示例 1:下载DMG文件(215MB)
用户: 下载 https://github.com/example/app/releases/download/v1.0/app.dmg
代理操作:
json
{
tool: exec,
command: curl -L -C - --progress-bar -o ~/Downloads/app.dmg https://github.com/example/app/releases/download/v1.0/app.dmg,
background: true,
timeout: 600
}
返回: {status: running, sessionId: xxx}
然后定期轮询:
json
{
tool: process,
action: poll,
sessionId: xxx
}
下载完成后,验证:
json
{
tool: exec,
command: ls -lh ~/Downloads/app.dmg && file ~/Downloads/app.dmg
}
示例 2:下载小文件(<50MB)
对于小文件,可以简化处理:
bash
exec(command=curl -L -o ~/Downloads/small.pdf https://example.com/small.pdf, timeout=120)
小文件可以同步运行,但仍需设置超时。
超时参考
| 文件大小 | 推荐超时时间 |
|---|
| < 50MB | 120秒(2分钟) |
| 50-200MB |
300秒(5分钟) |
| 200-500MB | 600秒(10分钟) |
| 500MB-1GB | 1200秒(20分钟) |
| > 1GB | 1800秒(30分钟)或更长 |
错误处理
常见错误及解决方案
1. 下载中断
bash
重新运行相同命令,curl -C - 会自动续传
curl -L -C - --progress-bar -o file.zip <网址>
2. 权限被拒绝
bash
确保目标目录可写
mkdir -p ~/Downloads
3. 重定向失败
bash
使用 -L 标志跟随重定向
curl -L -o file.zip <网址>
4. 网络超时
bash
增加超时时间或使用 --retry
curl -L --retry 3 --connect-timeout 30 -o file.zip <网址>
高级选项
多线程下载(aria2)
如果 aria2 可用,使用多线程实现更快的下载:
bash
exec(
command=aria2c -x 16 -s 16 -k 1M --continue -o ~/Downloads/file.zip <网址>,
background=true,
timeout=600
)
带进度监控的完整流程
bash
1. 开始下载
exec(command=curl -L -C - --progress-bar -o ~/Downloads/file.zip <网址>, background=true, timeout=600)
2. 每30秒轮询
process(action=poll, sessionId=xxx)
3. 完成后验证
exec(command=ls -lh ~/Downloads/file.zip)
4. 可选:计算校验和
exec(command=md5sum ~/Downloads/file.zip)
安全考虑
- 1. 仅从可信来源下载 - 验证网址来源
- 检查文件类型 - 使用 file 命令验证
- 扫描病毒 - 如有需要,下载后扫描
- 不要覆盖重要文件 - 检查目标文件是否已存在
相关技能
- - feishu-send-file - 将下载的文件发送到飞书
- file-read - 读取下载的文件内容
- video-frames - 如果是视频文件则提取帧
故障排除
如果下载失败,请按以下步骤操作:
- 1. 检查网络连接
bash
curl -I <网址>
- 2. 检查磁盘空间
bash
df -h ~/Downloads
- 3. 查看详细错误
bash
curl -v -o /dev/null <网址>
- 4. 尝试替代工具
bash
wget --continue <网址>
记住:对于大文件下载,始终使用 background=true! 🎯