Skip to content

Instantly share code, notes, and snippets.

@jweisman jweisman/
Last active Nov 1, 2016

What would you like to do?
Shell script to add a file to an Alma Digital representation
FILENAME=`basename "$1"`
if [ $# -lt 2 ]; then
echo "Usage: `basename $0` file-name representation-id [file-label]"
exit 0
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" "$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>" "$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.