Install
openclaw skills install tmpfiles-upload-stdlibUpload a local file to tmpfiles.org using Python standard library only, then return a direct download link in strict JSON.
openclaw skills install tmpfiles-upload-stdlibUse this skill when the user wants to upload a local file that already exists in the OpenClaw workspace or container and receive a temporary public download link.
This skill is for:
This skill is not for:
Before uploading, always check the following:
Never upload:
If the file appears sensitive, warn the user briefly before proceeding.
You need:
/root/.openclaw/workspace-default/report.pdfIf no local file path is available, ask for it or explain that the file must already exist locally in the workspace/container.
Always return strict JSON only with no markdown and no extra commentary.
Success format:
{
"success": true,
"file_path": "/root/.openclaw/workspace-default/report.pdf",
"file_name": "report.pdf",
"download_url": "https://tmpfiles.org/xxxxxxxx/report.pdf",
"note": "Temporary public link generated."
}
Failure format:
{
"success": false,
"file_path": "/root/.openclaw/workspace-default/report.pdf",
"error": "File not found"
}
Follow these steps exactly:
Use python3 and standard library modules only.
Preferred approach:
os for file checksmimetypes for content type guess if neededurllib.request and uuid for multipart uploadjson for parsing responseUse a one-shot Python command or heredoc script.
python3 <<'PY'
import os
import json
import uuid
import mimetypes
import urllib.request
file_path = "/absolute/path/to/file.ext"
if not os.path.isfile(file_path):
print(json.dumps({
"success": False,
"file_path": file_path,
"error": "File not found"
}))
raise SystemExit(0)
file_name = os.path.basename(file_path)
mime_type = mimetypes.guess_type(file_name)[0] or "application/octet-stream"
boundary = "----WebKitFormBoundary" + uuid.uuid4().hex
with open(file_path, "rb") as f:
file_bytes = f.read()
body = []
body.append(f"--{boundary}\r\n".encode())
body.append(
f'Content-Disposition: form-data; name="file"; filename="{file_name}"\r\n'.encode()
)
body.append(f"Content-Type: {mime_type}\r\n\r\n".encode())
body.append(file_bytes)
body.append(f"\r\n--{boundary}--\r\n".encode())
data = b"".join(body)
req = urllib.request.Request(
"https://tmpfiles.org/api/v1/upload",
data=data,
headers={
"Content-Type": f"multipart/form-data; boundary={boundary}",
"Accept": "application/json"
},
method="POST"
)
try:
with urllib.request.urlopen(req, timeout=60) as resp:
raw = resp.read().decode("utf-8", errors="replace")
parsed = json.loads(raw)
download_url = None
if isinstance(parsed, dict):
data_obj = parsed.get("data", {})
if isinstance(data_obj, dict):
download_url = data_obj.get("url")
if download_url:
print(json.dumps({
"success": True,
"file_path": file_path,
"file_name": file_name,
"download_url": download_url,
"note": "Temporary public link generated."
}))
else:
print(json.dumps({
"success": False,
"file_path": file_path,
"error": "Upload response did not include a download URL",
"raw_response": parsed
}))
except Exception as e:
print(json.dumps({
"success": False,
"file_path": file_path,
"error": str(e)
}))
PY
/absolute/path/to/file.ext with the real local file path.requests.Decline or warn when:
In those cases, suggest using private storage such as S3 or Supabase instead.