Skip to content

Instantly share code, notes, and snippets.

@maxiimilian
Created June 30, 2022 15:53
Show Gist options
  • Save maxiimilian/03cbbf1622daf23808c867e3b1726f2f to your computer and use it in GitHub Desktop.
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.
#!/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
@maxiimilian
Copy link
Author

Example: cat important_file | pasta.sh.

@amnesiacsardine
Copy link

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