From c118e804f949544979687ee865d1471e624ca801 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 8 Feb 2014 23:38:42 +0100 Subject: Updated help page. --- templates/help.tmpl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/templates/help.tmpl b/templates/help.tmpl index afba84a..d33ca77 100644 --- a/templates/help.tmpl +++ b/templates/help.tmpl @@ -3,12 +3,18 @@ #extends templates.base #def content

Usage: POST to $scheme://${host}${settings.virtual_root}u with filedata given to "file" and original filename to "filename". Login is done by generating a login token and sending it as the cookie "token".

-

TODO: Add info on how to generate a login token.

-

cURL example: -

curl -b 'token=foo' -F 'file=@image.png' -F 'filename=image.png' -F 'api=1' http://myhost/u
+

cURL examples, get_token: +

$ curl $scheme://${host}${settings.virtual_root}a?method=get_token -F username=foo -F password=bar
+{"status": true, "message": null, "method": "get_token", "token": "cb42eb38eb516d9dfcaaa742d1da0b3ad454b2bd05a8b4daa6d01e9587d7c759"}
+ Upload using the token: +
$ curl -b 'token=cb42eb38eb516d9dfcaaa742d1da0b3ad454b2bd05a8b4daa6d01e9587d7c759' -F 'file=@image.png' -F 'filename=image.png' -F 'api=1' $scheme://${host}${settings.virtual_root}u
+OK sjLUD
+ To expire the current token: +
$ curl $scheme://${host}${settings.virtual_root}a?method=expire_token -F token=cb42eb38eb516d9dfcaaa742d1da0b3ad454b2bd05a8b4daa6d01e9587d7c759
+{"status": true, "message": null, "method": "expire_token"}
If you get HTTP 417 responses, try adding:-H 'Expect:'.

By adding the key-value pair "api=1" you will get machine-readable responses in the form: response result where response is either ERROR or OK, - and result is the file hash in the case of OK, or an error message in the case of ERROR. + and result is the file hash in the case of OK, or an error message in the case of ERROR (see example above). The hash can be used to construct URLs in which the paths begin with /f/hash where hash is the hash received.

Any file extension an be appended to the hash, and for convenience the original filename (or whatever filename you prefer) can be appended after an additional slash after the hash.

#end def -- cgit v1.2.3