-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_curl.sh
51 lines (41 loc) · 1.01 KB
/
upload_curl.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
BASEURL=https://mami.cloudlab.zhaw.ch/mami/pto
CAMPAIGN=$1
BASEFILE=$2
if [ ! -f ${BASEFILE} ]; then
echo data file ${BASEFILE} missing
exit 1
fi
METAFILE=${BASEFILE}.meta.json
if [ ! -f ${METAFILE} ]; then
echo metadata file ${METAFILE} missing
exit 1
fi
echo Compressing ${BASEFILE}...
bzip2 $BASEFILE
BZFILE=${BASEFILE}.bz2
if [ ! -f ${METAFILE} ]; then
echo failed to compress: ${BZFILE} missing
exit 1
fi
echo "uploading metadata..."
curl -X PUT \
-H "Authorization: APIKEY `cat token`" \
-H "Content-type: application/json" \
${BASEURL}/raw/${CAMPAIGN}/${BZFILE} \
--data-binary @${METAFILE} | jq
rv=$?
if [ $rv -ne 0 ]; then
echo "failed to upload metadata, aborting"
exit $rv
fi
echo "uploading data..."
curl -X PUT \
-H "Authorization: APIKEY `cat token`" \
-H "Content-type: application/bzip2" \
${BASEURL}/raw/${CAMPAIGN}/${BZFILE}/data \
--data-binary @${BZFILE} | jq
rv=$?
if [ $rv -ne 0 ]; then
echo "failed to upload data, aborting"
exit $rv
fi