tmpfiles.org File Upload
Upload files to tmpfiles.org (temporary file hosting) and get a download link.
When to Use
- - Sending screenshots to Feishu when direct upload fails
- Sharing files temporarily (links expire after ~1 hour)
- Quick file sharing without authentication
Upload Script
CODEBLOCK0
Usage in OpenClaw
Step 1: Capture screenshot (if needed)
CODEBLOCK1
Step 2: Upload to tmpfiles.org
CODEBLOCK2
Step 3: Send link via message
CODEBLOCK3
Notes
- - Links expire after ~1 hour
- Max file size: ~100MB
- Files are publicly accessible while active
- Not suitable for sensitive/permanent storage
技能名称: tmpfiles-upload
详细描述:
tmpfiles.org 文件上传
将文件上传到 tmpfiles.org(临时文件托管)并获取下载链接。
使用场景
- - 当直接上传失败时,向飞书发送截图
- 临时分享文件(链接约1小时后过期)
- 无需身份验证的快速文件分享
上传脚本
python
import requests
def uploadtotmpfiles(file_path):
将文件上传到 tmpfiles.org 并返回下载 URL
with open(file_path, rb) as f:
r = requests.post(https://tmpfiles.org/api/v1/upload, files={file: f})
data = r.json()
if data.get(status) == success:
# 将 org/ 替换为 org/dl/ 以获取直接下载链接
return data[data][url].replace(org/, org/dl/)
raise Exception(f上传失败: {data})
在 OpenClaw 中的使用
步骤 1:截取屏幕截图(如需)
bash
/usr/sbin/screencapture -x ~/Desktop/screenshot.png
步骤 2:上传到 tmpfiles.org
bash
python3 -c
import requests
with open(/path/to/file.png, rb) as f:
r = requests.post(https://tmpfiles.org/api/v1/upload, files={file: f})
d = r.json()
if d.get(status) == success:
print(d[data][url].replace(org/, org/dl/))
步骤 3:通过消息发送链接
json
{
action: send,
channel: feishu,
message: 文件链接:https://tmpfiles.org/dl/xxx,
target: user_id
}
注意事项
- - 链接约1小时后过期
- 最大文件大小:约100MB
- 文件在有效期内可公开访问
- 不适用于敏感或永久存储