diff options
author | gretchen <gretchen@gnar.cool> | 2019-11-18 15:55:14 -0800 |
---|---|---|
committer | gretchen <gretchen@gnar.cool> | 2019-11-18 15:55:14 -0800 |
commit | c7d555f9cc243ebf37a13a723a635590faeeadb6 (patch) | |
tree | 17a7b0e4170d499159cfff97d31ff175dbd5104d /norns_upload | |
parent | a280edac7a0a2be59e128920ab58e265452aa864 (diff) | |
download | norns-etc-c7d555f9cc243ebf37a13a723a635590faeeadb6.tar.gz norns-etc-c7d555f9cc243ebf37a13a723a635590faeeadb6.zip |
Upload script.
Diffstat (limited to 'norns_upload')
-rw-r--r-- | norns_upload | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/norns_upload b/norns_upload new file mode 100644 index 0000000..e6759b8 --- /dev/null +++ b/norns_upload @@ -0,0 +1,31 @@ +#!/bin/bash + +set -x + +if [[ $# -ne 2 ]]; then + echo "Usage: $0 project filename" + exit 1 +fi + +HOST=norns.local +API="/api/v1" +BASE="/dust/code/" +PROJECT="$1" +FILE="$2" + +LOCAL_FILE="$FILE" +URL="http://$HOST$API$BASE$PROJECT/$FILE" + +TEMP="$(mktemp)" +BOUNDARY="----$(head -c70 < <(tr -dc '\101-\132\141-\172' < /dev/urandom))" + +function finish { + rm -f "$TEMP" +} +trap finish EXIT + +echo "--$BOUNDARY"$'\r\nContent-Disposition: form-data; name="value"; filename="blob"\r\nContent-Type: text/utf-8\r\n\r' > $TEMP +cat < "$LOCAL_FILE" >> $TEMP +echo $'\r\n'"--$BOUNDARY--"$'\r\n' >> $TEMP + +curl "$URL" -X PUT -H "Content-Type: multipart/form-data; boundary=$BOUNDARY" --data-binary @$TEMP --compressed --silent > /dev/null |