Skip to content

Instantly share code, notes, and snippets.

@althafvly
Created May 8, 2023 19:08
Show Gist options
  • Save althafvly/42cb7328bafb8ed76009ea26e253a6f6 to your computer and use it in GitHub Desktop.
Save althafvly/42cb7328bafb8ed76009ea26e253a6f6 to your computer and use it in GitHub Desktop.
Script to upload to pixeldrain.com and return url
#!/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