Skip to content

Instantly share code, notes, and snippets.

@leplatrem
Created July 2, 2018 10:34
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 leplatrem/b67c3465321d61aa05e3f07f8f3ca05a to your computer and use it in GitHub Desktop.
Save leplatrem/b67c3465321d61aa05e3f07f8f3ca05a to your computer and use it in GitHub Desktop.
SERVER=https://kinto.dev.mozaws.net/v1
BUCKET=main
COLLECTION=public-suffix-list
RECORD=b719eacd-96ed-4979-bfd8-538fd39d9c05 # uuidgen
echo
echo "Create user"
curl -X PUT ${SERVER}/accounts/psl \
-H 'Content-Type:application/json' \
-d '{"data": {"password": "psl-secret"}}' \
-u psl:psl-secret
echo
echo "Create collection"
curl -X PUT ${SERVER}/buckets/${BUCKET}/collections/${COLLECTION} \
-H 'Content-Type:application/json' \
-u psl:psl-secret
echo
echo "Create record with attachment"
curl -X POST ${SERVER}/buckets/${BUCKET}/collections/${COLLECTION}/records/${RECORD}/attachment \
-H 'Content-Type:multipart/form-data' \
-F 'data={"property": 42}' \
-F 'attachment=@/home/mathieu/DAFSA.bin' \
-u psl:psl-secret
base_url=`curl -s {$SERVER}/ | jq .capabilities.attachments.base_url`
echo
echo "Base URL for attachments is ${base_url}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment