Created
February 9, 2026 23:54
-
-
Save swarm-protocol/55e51d20e45593e86a2fd9b2600cda42 to your computer and use it in GitHub Desktop.
bash uploader for litterbox.catbox.moe (useful for HTML5 apps)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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