Created
June 30, 2022 15:53
-
-
Save maxiimilian/03cbbf1622daf23808c867e3b1726f2f to your computer and use it in GitHub Desktop.
Companion script for microbin server. Pipe everything to `pasta.sh` to quickly create pastas. The link will be returned to stdout.
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 | |
# Set microbin server URL here | |
BASE_URL=xxxxxxxx | |
# Take expiration time as input and default to 10 minutes. | |
if [[ "$1" == "" ]]; then | |
expiration=10min | |
else | |
expiration=$1 | |
fi | |
# Post everything from stdin to microbin and save resulting stored url. | |
pasta_url=$(cat /dev/stdin | curl -v -F expiration=$expiration -F content=@- $BASE_URL/upload 2>&1 | grep location | sed 's/^< location: \(.*\)$/\1/') | |
# Return full pasta url | |
echo $BASE_URL$pasta_url |
That's awesome! Thank you for that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
cat important_file | pasta.sh
.