Skip to content

Instantly share code, notes, and snippets.

@swarm-protocol
Created February 9, 2026 23:54
Show Gist options
  • Select an option

  • Save swarm-protocol/55e51d20e45593e86a2fd9b2600cda42 to your computer and use it in GitHub Desktop.

Select an option

Save swarm-protocol/55e51d20e45593e86a2fd9b2600cda42 to your computer and use it in GitHub Desktop.
bash uploader for litterbox.catbox.moe (useful for HTML5 apps)
#!/usr/bin/env bash
set -euo pipefail
# Configuration
LOG_FILE="${HOME}/litterbox.log"
API_ENDPOINT="https://litterbox.catbox.moe/resources/internals/api.php"
CATBOX_TIME="${CATBOX_TIME:-72h}" # Default 72h, override via env
# Usage
usage() {
echo "Usage: $0 <file> [time]"
echo " time: 1h, 12h, 24h, 72h (default: 72h)"
exit 1
}
# Validate
[[ $# -lt 1 ]] && usage
FILE_PATH="$1"
TIME_PARAM="${2:-$CATBOX_TIME}"
[[ ! -f "$FILE_PATH" ]] && { echo "Error: File not found"; exit 1; }
[[ ! "$TIME_PARAM" =~ ^(1h|12h|24h|72h)$ ]] && { echo "Error: Invalid time"; exit 1; }
# Upload
echo "[$(date -Iseconds)] Uploading: $FILE_PATH (expires: $TIME_PARAM)" | tee -a "$LOG_FILE"
RESPONSE=$(curl -sS -F "reqtype=fileupload" \
-F "time=$TIME_PARAM" \
-F "fileToUpload=@$FILE_PATH" \
"$API_ENDPOINT")
# Log result
if [[ "$RESPONSE" =~ ^https:// ]]; then
echo "[$(date -Iseconds)] ✓ Success: $RESPONSE" | tee -a "$LOG_FILE"
echo "$RESPONSE"
exit 0
else
echo "[$(date -Iseconds)] ✗ Failed: $RESPONSE" | tee -a "$LOG_FILE" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment