2015-10-09 03:48:06 +02:00
{% extends "base.html" %}
{% block head %}
2015-10-30 23:36:47 +01:00
< link href = "{{ sitepath }}static/css/github-markdown.css" rel = "stylesheet" type = "text/css" >
2015-10-09 03:48:06 +02:00
{% endblock %}
{% block content %}
< div id = "main" >
< div id = 'inner_content' >
< div class = "normal markdown-body" >
< h2 > API< / h2 >
2015-10-15 23:26:35 +02:00
< h3 > Client< / h3 >
< p > To simplify uploading and deleting files, you can use < a target = "_blank" href = "https://github.com/andreimarcu/linx-client" > linx-client< / a > , which uses this API.< / p >
2015-10-14 22:47:13 +02:00
{% if using_auth %}
< h3 > Keys< / h3 >
< p > This instance uses API Keys, therefore you will need to provide a key for uploading and deleting files.< br / > To do so, add the < code > Linx-Api-Key< / code > header with your key.< / p >
{% endif %}
2015-10-09 03:48:06 +02:00
< h3 > Uploading a file< / h3 >
< p > To upload a file, make a PUT request to < code > {{ siteurl }}upload/< / code > and you will get the url of your upload back.< / p >
< p > < strong > Optional headers with the request< / strong > < / p >
2019-01-26 11:04:32 +01:00
{% if not forcerandom %}
2015-10-09 03:48:06 +02:00
< p > Randomize the filename< br / >
< code > Linx-Randomize: yes< / code > < / p >
2019-01-26 11:04:32 +01:00
{% endif %}
2015-10-09 03:48:06 +02:00
< p > Specify a custom deletion key< br / >
< code > Linx-Delete-Key: mysecret< / code > < / p >
2020-03-01 02:00:39 +01:00
< p > Protect file with password< br / >
< code > Linx-Access-Key: mysecret< / code > < / p >
2015-10-09 03:48:06 +02:00
< p > Specify an expiration time (in seconds)< br / >
< code > Linx-Expiry: 60< / code > < / p >
< p > Get a json response< br / >
< code > Accept: application/json< / code > < / p >
< p > The json response will then contain:< / p >
< blockquote >
< p > “url”: the publicly available upload url< br / >
2019-01-15 01:16:15 +01:00
“direct_url”: the url to access the file directly< br / >
2015-10-09 03:48:06 +02:00
“filename”: the (optionally generated) filename< br / >
“delete_key”: the (optionally generated) deletion key,< br / >
2020-03-01 02:00:39 +01:00
“access_key”: the (optionally generated) access key,< br / >
2015-10-09 03:48:06 +02:00
“expiry”: the unix timestamp at which the file will expire (0 if never)< br / >
“size”: the size in bytes of the file< br / >
“mimetype”: the guessed mimetype of the file< br / >
“sha256sum”: the sha256sum of the file,< / p >
< / blockquote >
< p > < strong > Examples< / strong > < / p >
< p > Uploading myphoto.jpg< / p >
2015-10-14 22:47:13 +02:00
{% if using_auth %}
< pre > < code > $ curl -H " Linx-Api-Key: mysecretkey" -T myphoto.jpg {{ siteurl }}upload/
2019-01-26 11:04:32 +01:00
{{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}7z4h4ut.jpg{% endif %}< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% else %}
2015-10-09 03:48:06 +02:00
< pre > < code > $ curl -T myphoto.jpg {{ siteurl }}upload/
2019-01-26 11:04:32 +01:00
{{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}wtq7pan.jpg{% endif %}< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% endif %}
2015-10-09 03:48:06 +02:00
< p > Uploading myphoto.jpg with an expiry of 20 minutes< / p >
2015-10-14 22:47:13 +02:00
{% if using_auth %}
< pre > < code > $ curl -H " Linx-Api-Key: mysecretkey" -H " Linx-Expiry: 1200" -T myphoto.jpg {{ siteurl }}upload/
2019-01-26 11:04:32 +01:00
{{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}jm295snf.jpg{% endif %}< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% else %}
2015-10-09 03:48:06 +02:00
< pre > < code > $ curl -H " Linx-Expiry: 1200" -T myphoto.jpg {{ siteurl }}upload/
2019-01-26 11:04:32 +01:00
{{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}1doym9u2.jpg{% endif %}< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% endif %}
2015-10-09 03:48:06 +02:00
< p > Uploading myphoto.jpg with a random filename and getting a json response:< / p >
2015-10-14 22:47:13 +02:00
{% if using_auth %}
2019-01-26 11:04:32 +01:00
< pre > < code > $ curl -H " Linx-Api-Key: mysecretkey" -H " Accept: application/json" {% if not forcerandom %} -H " Linx-Randomize: yes" {% endif %} -T myphoto.jpg {{ siteurl }}upload/
2015-10-14 22:47:13 +02:00
{" delete_key" :" ..." ," expiry" :" 0" ," filename" :" f34h4iu.jpg" ," mimetype" :" image/jpeg" ,
2016-06-04 09:20:20 +02:00
" sha256sum" :" ..." ," size" :" ..." ," url" :" {{ siteurl }}f34h4iu.jpg" }< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% else %}
2019-01-26 11:04:32 +01:00
< pre > < code > $ curl -H " Accept: application/json" {% if not forcerandom %} -H " Linx-Randomize: yes" {% endif %} -T myphoto.jpg {{ siteurl }}upload/
2015-10-09 03:48:06 +02:00
{" delete_key" :" ..." ," expiry" :" 0" ," filename" :" f34h4iu.jpg" ," mimetype" :" image/jpeg" ,
2016-06-04 09:20:20 +02:00
" sha256sum" :" ..." ," size" :" ..." ," url" :" {{ siteurl }}f34h4iu.jpg" }< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% endif %}
2015-10-09 03:48:06 +02:00
2015-10-12 02:28:46 +02:00
< h3 > Overwriting a file< / h3 >
< p > To overwrite a file you uploaded, simply provide the < code > Linx-Delete-Key< / code > header with the original file's deletion key.< / p >
< p > < strong > Example< / p > < / strong >
< p > To overwrite myphoto.jpg< / p >
2015-10-14 22:47:13 +02:00
{% if using_auth %}
< pre > < code > $ curl -H " Linx-Api-Key: mysecretkey" -H " Linx-Delete-Key: mysecret" -T myphoto.jpg {{ siteurl }}upload/
{{ siteurl }}myphoto.jpg< / code > < / pre >
{% else %}
2015-10-12 02:28:46 +02:00
< pre > < code > $ curl -H " Linx-Delete-Key: mysecret" -T myphoto.jpg {{ siteurl }}upload/
{{ siteurl }}myphoto.jpg< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% endif %}
2015-10-12 02:28:46 +02:00
2015-10-09 03:48:06 +02:00
< h3 > Deleting a file< / h3 >
< p > To delete a file you uploaded, make a DELETE request to < code > {{ siteurl }}yourfile.ext< / code > with the delete key set as the < code > Linx-Delete-Key< / code > header.< / p >
< p > < strong > Example< / strong > < / p >
< p > To delete myphoto.jpg< / p >
2015-10-14 22:47:13 +02:00
{% if using_auth %}
< pre > < code > $ curl -H " Linx-Api-Key: mysecretkey" -H " Linx-Delete-Key: mysecret" -X DELETE {{ siteurl }}myphoto.jpg
DELETED< / code > < / pre >
{% else %}
2015-10-09 03:48:06 +02:00
< pre > < code > $ curl -H " Linx-Delete-Key: mysecret" -X DELETE {{ siteurl }}myphoto.jpg
DELETED< / code > < / pre >
2015-10-14 22:47:13 +02:00
{% endif %}
2015-10-09 03:48:06 +02:00
< h3 > Information about a file< / h3 >
< p > To retrieve information about a file, make a GET request the public url with < code > Accept: application/json< / code > headers and you will receive a json response containing:< / p >
< blockquote >
< p > “url”: the publicly available upload url< br / >
2019-01-15 01:16:15 +01:00
“direct_url”: the url to access the file directly< br / >
2015-10-09 03:48:06 +02:00
“filename”: the (optionally generated) filename< br / >
“expiry”: the unix timestamp at which the file will expire (0 if never)< br / >
“size”: the size in bytes of the file< br / >
“mimetype”: the guessed mimetype of the file< br / >
“sha256sum”: the sha256sum of the file,< / p >
< / blockquote >
< p > < strong > Example< / strong > < / p >
2016-06-15 08:21:39 +02:00
< pre > < code > $ curl -H " Accept: application/json" {{ siteurl }}myphoto.jpg
2015-10-09 03:48:06 +02:00
{" expiry" :" 0" ," filename" :" myphoto.jpg" ," mimetype" :" image/jpeg" ," sha256sum" :" ..." ," size" :" ..." }< / code > < / pre >
< / div >
< / div >
< / div >
{% endblock %}