Last active
November 1, 2016 09:33
-
-
Save jweisman/3fe652f6f3817e5cc49fe1ef9478a317 to your computer and use it in GitHub Desktop.
Shell script to add a file to an Alma Digital representation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTITUTION="YOUR-INSTITUTION" | |
AWS_BUCKET="na-st01.ext.exlibrisgroup.com" | |
APIKEY="YOUR-API-KEY" | |
FILENAME=`basename "$1"` | |
if [ $# -lt 2 ]; then | |
echo "Usage: `basename $0` file-name representation-id [file-label]" | |
exit 0 | |
fi | |
echo Uploading $1 | |
aws s3 cp $1 s3://$AWS_BUCKET/$INSTITUTION/upload/$FILENAME | |
echo Getting BIB for rep id $2 | |
BIB=`curl -s -H "Authorization: apikey $APIKEY" -H "Accept: application/xml" "https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs?representation_id=$2" | xmllint --xpath "string(/bibs/bib/mms_id)" -` | |
echo Adding file to representation | |
curl -X POST -H "Authorization: apikey $APIKEY" -H "Content-type: application/xml" -H "Accept: application/json" --data "<representation_file><label>$3</label><path>$INSTITUTION/upload/$FILENAME</path></representation_file>" "https://api-na.hosted.exlibrisgroup.com/almaws/v1/bibs/$BIB/representations/$2/files" | |
echo File added. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment