Skip to content

Instantly share code, notes, and snippets.

@escowles
Created May 4, 2018 14:23
Show Gist options
  • Select an option

  • Save escowles/4e6f2a821c4ceb541ad6aca35148081c to your computer and use it in GitHub Desktop.

Select an option

Save escowles/4e6f2a821c4ceb541ad6aca35148081c to your computer and use it in GitHub Desktop.
#!/bin/sh
AUTH="-u fedoraAdmin:fedoraAdmin"
BASE="http://localhost:8080/rest/$RANDOM"
SUBJ="$BASE#me"
# create a direct container with a hash uri resource
echo creating direct container
curl $AUTH -X PUT -H "Content-type: text/turtle" -d "<$SUBJ> <http://purl.org/dc/title> 'my thing' ." $BASE
echo
# create an indirect container using the hash uri as the membership resource
TTL="<> a <http://www.w3.org/ns/ldp#IndirectContainer>;
<http://www.w3.org/ns/ldp#membershipResource> <$SUBJ>;
<http://www.w3.org/ns/ldp#hasMemberRelation> <http://pcdm.org/models#hasFile>;
<http://www.w3.org/ns/ldp#insertedContentRelation> <http://www.openarchives.org/ore/terms/proxyFor> ."
echo creating indirect
curl $AUTH -X PUT -H "Content-type: text/turtle" -H "Link: <http://www.w3.org/ns/ldp#IndirectContainer>;rel=\"type\"" -d "$TTL" $BASE/bar
echo
# create a file
echo creating file
curl $AUTH -X PUT -d "asdf" $BASE/file1
echo
# create a member of the indirect container
echo creating member
curl $AUTH -X POST -H "Content-type: text/turtle" -d "<> <http://www.openarchives.org/ore/terms/proxyFor> <$BASE/file1>" $BASE/bar
echo
# expect to see triples referencing the hash uri resource
echo fetching $BASE
curl $AUTH $BASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment