-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathzenodo_update.sh
More file actions
executable file
·35 lines (29 loc) · 844 Bytes
/
zenodo_update.sh
File metadata and controls
executable file
·35 lines (29 loc) · 844 Bytes
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
#!/bin/bash
# Update deposit with provided metadata.
#
# usage: ./zenodo_update.sh [deposit id] [metadata filename] [--verbose|-v]
#
set -ex
VERBOSE=0
if [ "$3" == "--verbose" ] || [ "$3" == "-v" ]; then
VERBOSE=1
fi
DEPOSIT="$1"
FILEPATH="$2"
FILENAME=$(echo $FILEPATH | sed 's+.*/++g')
FILENAME=${FILENAME// /%20}
ZENODO_ENDPOINT=${ZENODO_ENDPOINT:-https://zenodo.org}
DEPOSITION_ENDPOINT="${ZENODO_ENDPOINT}/api/deposit/depositions/${DEPOSIT}"
if [ "$VERBOSE" -eq 1 ]; then
echo "Deposition ID: ${DEPOSITION}"
echo "File path: ${FILEPATH}"
echo "File name: ${FILENAME}"
echo "Requesting to update deposition..."
fi
curl --progress-bar \
--retry 5 \
--retry-delay 5 \
-H "Content-Type: application/json" \
-X PUT\
--data "@${FILEPATH}" \
"${DEPOSITION_ENDPOINT}?access_token=${ZENODO_TOKEN}"