Add up, a handy little script for uploading a file or three to up.00dani.me

This commit is contained in:
Danielle McLean 2018-07-26 09:13:05 +10:00
parent adbab7baa0
commit 19b8f350cf
Signed by: 00dani
GPG key ID: 8EB789DDF3ABD240

24
local/bin/up Executable file
View file

@ -0,0 +1,24 @@
#!/bin/zsh
upload() {
http --check-status --ignore-stdin \
POST https://up.00dani.me/ \
Authorization:$UP_TOKEN \
Content-Type:$(file --mime-type -b $1) \
X-Filename:$1 \
@$1
}
if (( $# == 0 )); then
upload =(cat)
exit $?
fi
for f; do
if [[ ! -r $f ]]; then
print "up: $f is not a readable file" >&2
exit 1
fi
upload $f || exit $?
print
done