From 19b8f350cf8c0435477bd1205acf0aad80892855 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 26 Jul 2018 09:13:05 +1000 Subject: [PATCH] Add up, a handy little script for uploading a file or three to up.00dani.me --- local/bin/up | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 local/bin/up diff --git a/local/bin/up b/local/bin/up new file mode 100755 index 0000000..e25c7f5 --- /dev/null +++ b/local/bin/up @@ -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