blob: dd4dba6649efedf272a0b5d7c152c9bd9031a11f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "Usage: $0 project filename"
exit 1
fi
HOST="${NORNS:-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
|