Skip to content

Instantly share code, notes, and snippets.

@kefo
Last active February 7, 2017 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kefo/40ddf654ef96edce523b2559dae26c1a to your computer and use it in GitHub Desktop.
Save kefo/40ddf654ef96edce523b2559dae26c1a to your computer and use it in GitHub Desktop.
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
INSERT {
<> dc:title 'T 1' .
<> dc:creator 'kefo' .
} WHERE {
<> rdf:type <http://fedora.info/definitions/v4/repository#Binary>
}
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<>
dc:title "T 1" ;
dc:creator "kefo" .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<>
dc:title "T 2" ;
dc:creator "kefo" .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<>
dc:title "T 1" ;
dc:creator "kefo" .
#!/bin/bash
#############
#
#############
pfx="http://192.168.99.100:8080/fcrepo/rest/prod"
uuid=$(uuidgen)
resource="${pfx}/${uuid}"
echo; echo; echo;
echo; echo; echo;
# This merely demonstrates PUTting an RDF resource and then replacing it.
echo; echo; echo;
echo; echo; echo;
echo; echo "This merely demonstrates PUTting an RDF resource and then replacing it."; echo;
echo; echo; echo "PUTting RDF resource."
curl -X PUT -H "Content-type: application/turtle" -i --data-binary @add_title1.ttl "${resource}"
echo; echo; echo "Let's see what the RDF - ${resource} - looks like now."
curl -i "${resource}"
echo; echo; echo "Replacing (PUTting) a new RDF resource. dc:title should change."
curl -X PUT -H "Content-type: application/turtle" -H "Prefer: handling=lenient; received=\"minimal\"" -i --data-binary @add_title2.ttl "${resource}"
echo; echo; echo "Let's see what the RDF - ${resource} - looks like now."
curl -i "${resource}"
# This demonstrates PATCHing the RDF resource (fcr:metadata) that describes the binary.
echo; echo; echo;
echo; echo; echo;
curl https://cdn.loc.gov/service/pnp/fsa/8d23000/8d23200/8d23214v.jpg > railroad.jpg
uuid=$(uuidgen)
resource="${pfx}/${uuid}"
echo; echo "This demonstrates PATCHing the RDF resource (fcr:metadata) that describes the binary."; echo;
echo; echo; echo "Creating Container ${resource}."
curl -iXPUT -H "Content-type: image/jpeg" --data-binary @railroad.jpg "${resource}"
echo; echo; echo "Let's see what the metadata - ${resource} - looks like."
curl -i "${resource}/fcr:metadata"
echo; echo; echo "Adding title to fcr:metadata via PATCH."
curl -X PATCH -H "Content-type: application/sparql-update" -i --data-binary @add_title1.sparql "${resource}/fcr:metadata"
echo; echo; echo "Let's see what the metadata - ${resource}/fcr:metadata - looks like now."
curl -i "${resource}/fcr:metadata"
# This demonstrates PUTting a binary resource and then attempting to relace its metadata (fcr:metadata) via PUT
echo; echo; echo;
echo; echo; echo;
curl https://cdn.loc.gov/service/pnp/cph/3c00000/3c01000/3c01100/3c01148v.jpg > state-street.jpg
uuid=$(uuidgen)
resource="${pfx}/${uuid}"
echo; echo "This demonstrates PUTting a binary resource and then attempting to relace its metadata (fcr:metadata) via PUT."; echo;
echo; echo; echo "PUTting binary resource - ${resource}."
curl -iXPUT -H "Content-type: image/jpeg" --data-binary @state-street.jpg "${resource}"
echo; echo; echo "Let's see what the metadata - ${resource} - looks like."
curl -i "${resource}/fcr:metadata"
echo; echo; echo "Adding dc:title and dc:creator to fcr:metadata via PUT."
curl -X PUT -H "Content-type: application/turtle" -H "Prefer: handling=lenient; received=\"minimal\"" -i --data-binary @add_title3.ttl "${resource}/fcr:metadata"
echo; echo; echo "Let's see what the metadata - ${resource} - looks like now."
curl -i "${resource}/fcr:metadata"
echo; echo; echo;
echo; echo; echo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment