Skip to content

Instantly share code, notes, and snippets.

@jweisman jweisman/add-file.sh
Last active Nov 1, 2016

Embed
What would you like to do?
Shell script to add a file to an Alma Digital representation
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
You can’t perform that action at this time.