Skip to content

Instantly share code, notes, and snippets.

@ushis
Last active March 31, 2017 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ushis/5354917 to your computer and use it in GitHub Desktop.
Save ushis/5354917 to your computer and use it in GitHub Desktop.
# Uploads files to honkgong.
#
# Specify some files like so:
#
# put <file> [<file> ...]
#
# Or pipe some data into it:
#
# cat file1 file2 | put
#
# Have a nice day!
put() {
local f url='https://put.honkgong.info'
# Read from stdin, if there are no arguments.
if [ $# -eq 0 ]; then
curl --data-binary @- "${url}"
return $?
fi
# Try to send every provided file.
for f in $*; do
if [ ! -r "${f}" ]; then
print "Can't read:" "${f}" 1>&2
else
curl -T "${f}" -H "Content-Type: $(file -b --mime-type ${f})" "${url}"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment