From 256ca43d69edc4794a7dfab8533964d47c593077 Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Wed, 14 Oct 2015 16:47:13 -0400 Subject: [PATCH] Update API documentation with API keys --- templates/API.html | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/templates/API.html b/templates/API.html index 68cf035..215bf38 100644 --- a/templates/API.html +++ b/templates/API.html @@ -11,6 +11,11 @@

API

+ {% if using_auth %} +

Keys

+

This instance uses API Keys, therefore you will need to provide a key for uploading and deleting files.
To do so, add the Linx-Api-Key header with your key.

+ {% endif %} +

Uploading a file

To upload a file, make a PUT request to {{ siteurl }}upload/ and you will get the url of your upload back.

@@ -45,19 +50,35 @@

Uploading myphoto.jpg

+ {% if using_auth %} +
$ curl -H "Linx-Api-Key: mysecretkey" -T myphoto.jpg {{ siteurl }}upload/  
+{{ siteurl }}myphoto.jpg
+ {% else %}
$ curl -T myphoto.jpg {{ siteurl }}upload/  
 {{ siteurl }}myphoto.jpg
+ {% endif %}

Uploading myphoto.jpg with an expiry of 20 minutes

+ {% if using_auth %} +
$ curl -H "Linx-Api-Key: mysecretkey" -H "Linx-Expiry: 1200" -T myphoto.jpg {{ siteurl }}upload/
+{{ siteurl }}myphoto.jpg
+ {% else %}
$ curl -H "Linx-Expiry: 1200" -T myphoto.jpg {{ siteurl }}upload/
 {{ siteurl }}myphoto.jpg
+ {% endif %}

Uploading myphoto.jpg with a random filename and getting a json response:

+ {% if using_auth %} +
$ curl -H "Linx-Api-Key: mysecretkey" -H "Accept: application/json" -H "Linx-Randomize: yes" -T myphoto.jpg {{ siteurl }}/upload/  
+{"delete_key":"...","expiry":"0","filename":"f34h4iu.jpg","mimetype":"image/jpeg",
+"sha256sum":"...","size":"...","url":"{{ steurl }}/f34h4iu.jpg"}
+ {% else %}
$ curl -H "Accept: application/json" -H "Linx-Randomize: yes" -T myphoto.jpg {{ siteurl }}/upload/  
 {"delete_key":"...","expiry":"0","filename":"f34h4iu.jpg","mimetype":"image/jpeg",
 "sha256sum":"...","size":"...","url":"{{ steurl }}/f34h4iu.jpg"}
+ {% endif %}

Overwriting a file

@@ -67,8 +88,13 @@

To overwrite myphoto.jpg

+ {% if using_auth %} +
$ curl -H "Linx-Api-Key: mysecretkey" -H "Linx-Delete-Key: mysecret" -T myphoto.jpg {{ siteurl }}upload/
+{{ siteurl }}myphoto.jpg
+ {% else %}
$ curl -H "Linx-Delete-Key: mysecret" -T myphoto.jpg {{ siteurl }}upload/
 {{ siteurl }}myphoto.jpg
+ {% endif %}

Deleting a file

@@ -78,8 +104,13 @@

To delete myphoto.jpg

+ {% if using_auth %} +
$ curl -H "Linx-Api-Key: mysecretkey" -H "Linx-Delete-Key: mysecret" -X DELETE {{ siteurl }}myphoto.jpg
+DELETED
+ {% else %}
$ curl -H "Linx-Delete-Key: mysecret" -X DELETE {{ siteurl }}myphoto.jpg
 DELETED
+ {% endif %}

Information about a file