Created
May 8, 2023 19:08
-
-
Save althafvly/42cb7328bafb8ed76009ea26e253a6f6 to your computer and use it in GitHub Desktop.
Script to upload to pixeldrain.com and return url
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
#!/bin/bash | |
# Check if filename argument was provided | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <filename>" # Print usage message | |
exit 1 # Exit with error code | |
fi | |
# Upload file to PixelDrain | |
response=$(curl -s -X PUT https://pixeldrain.com/api/file/ -T "$1" -H 'Content-Type: application/zip') | |
# Parse ID from JSON response | |
id=$(echo "$response" | jq -r '.id') | |
# Check if response JSON is empty or has no ID | |
if [ -n "$id" ]; then | |
# Print URL | |
echo "https://pixeldrain.com/u/$id" | |
else | |
echo "Error: Upload failed or response JSON is empty" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment