Contains the Concourse pipeline definition for building a line-server container
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
6.0 KiB

  1. {% extends "base.html" %}
  2. {% block head %}
  3. <link href="{{ sitepath }}static/css/github-markdown.css" rel="stylesheet" type="text/css">
  4. {% endblock %}
  5. {% block content %}
  6. <div id="main">
  7. <div id='inner_content'>
  8. <div class="normal markdown-body">
  9. <h2>API</h2>
  10. <h3>Client</h3>
  11. <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>
  12. {% if using_auth %}
  13. <h3>Keys</h3>
  14. <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>
  15. {% endif %}
  16. <h3>Uploading a file</h3>
  17. <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>
  18. <p><strong>Optional headers with the request</strong></p>
  19. {% if not forcerandom %}
  20. <p>Randomize the filename<br/>
  21. <code>Linx-Randomize: yes</code></p>
  22. {% endif %}
  23. <p>Specify a custom deletion key<br/>
  24. <code>Linx-Delete-Key: mysecret</code></p>
  25. <p>Specify an expiration time (in seconds)<br/>
  26. <code>Linx-Expiry: 60</code></p>
  27. <p>Get a json response<br/>
  28. <code>Accept: application/json</code></p>
  29. <p>The json response will then contain:</p>
  30. <blockquote>
  31. <p>“url”: the publicly available upload url<br/>
  32. “direct_url”: the url to access the file directly<br/>
  33. “filename”: the (optionally generated) filename<br/>
  34. “delete_key”: the (optionally generated) deletion key,<br/>
  35. “expiry”: the unix timestamp at which the file will expire (0 if never)<br/>
  36. “size”: the size in bytes of the file<br/>
  37. “mimetype”: the guessed mimetype of the file<br/>
  38. “sha256sum”: the sha256sum of the file,</p>
  39. </blockquote>
  40. <p><strong>Examples</strong></p>
  41. <p>Uploading myphoto.jpg</p>
  42. {% if using_auth %}
  43. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -T myphoto.jpg {{ siteurl }}upload/
  44. {{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}7z4h4ut.jpg{% endif %}</code></pre>
  45. {% else %}
  46. <pre><code>$ curl -T myphoto.jpg {{ siteurl }}upload/
  47. {{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}wtq7pan.jpg{% endif %}</code></pre>
  48. {% endif %}
  49. <p>Uploading myphoto.jpg with an expiry of 20 minutes</p>
  50. {% if using_auth %}
  51. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Linx-Expiry: 1200&#34; -T myphoto.jpg {{ siteurl }}upload/
  52. {{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}jm295snf.jpg{% endif %}</code></pre>
  53. {% else %}
  54. <pre><code>$ curl -H &#34;Linx-Expiry: 1200&#34; -T myphoto.jpg {{ siteurl }}upload/
  55. {{ siteurl }}{% if not forcerandom %}myphoto.jpg{% else %}1doym9u2.jpg{% endif %}</code></pre>
  56. {% endif %}
  57. <p>Uploading myphoto.jpg with a random filename and getting a json response:</p>
  58. {% if using_auth %}
  59. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Accept: application/json&#34;{% if not forcerandom %} -H &#34;Linx-Randomize: yes&#34;{% endif %} -T myphoto.jpg {{ siteurl }}upload/
  60. {&#34;delete_key&#34;:&#34;...&#34;,&#34;expiry&#34;:&#34;0&#34;,&#34;filename&#34;:&#34;f34h4iu.jpg&#34;,&#34;mimetype&#34;:&#34;image/jpeg&#34;,
  61. &#34;sha256sum&#34;:&#34;...&#34;,&#34;size&#34;:&#34;...&#34;,&#34;url&#34;:&#34;{{ siteurl }}f34h4iu.jpg&#34;}</code></pre>
  62. {% else %}
  63. <pre><code>$ curl -H &#34;Accept: application/json&#34;{% if not forcerandom %} -H &#34;Linx-Randomize: yes&#34;{% endif %} -T myphoto.jpg {{ siteurl }}upload/
  64. {&#34;delete_key&#34;:&#34;...&#34;,&#34;expiry&#34;:&#34;0&#34;,&#34;filename&#34;:&#34;f34h4iu.jpg&#34;,&#34;mimetype&#34;:&#34;image/jpeg&#34;,
  65. &#34;sha256sum&#34;:&#34;...&#34;,&#34;size&#34;:&#34;...&#34;,&#34;url&#34;:&#34;{{ siteurl }}f34h4iu.jpg&#34;}</code></pre>
  66. {% endif %}
  67. <h3>Overwriting a file</h3>
  68. <p>To overwrite a file you uploaded, simply provide the <code>Linx-Delete-Key</code> header with the original file's deletion key.</p>
  69. <p><strong>Example</p></strong>
  70. <p>To overwrite myphoto.jpg</p>
  71. {% if using_auth %}
  72. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Linx-Delete-Key: mysecret&#34; -T myphoto.jpg {{ siteurl }}upload/
  73. {{ siteurl }}myphoto.jpg</code></pre>
  74. {% else %}
  75. <pre><code>$ curl -H &#34;Linx-Delete-Key: mysecret&#34; -T myphoto.jpg {{ siteurl }}upload/
  76. {{ siteurl }}myphoto.jpg</code></pre>
  77. {% endif %}
  78. <h3>Deleting a file</h3>
  79. <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>
  80. <p><strong>Example</strong></p>
  81. <p>To delete myphoto.jpg</p>
  82. {% if using_auth %}
  83. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Linx-Delete-Key: mysecret&#34; -X DELETE {{ siteurl }}myphoto.jpg
  84. DELETED</code></pre>
  85. {% else %}
  86. <pre><code>$ curl -H &#34;Linx-Delete-Key: mysecret&#34; -X DELETE {{ siteurl }}myphoto.jpg
  87. DELETED</code></pre>
  88. {% endif %}
  89. <h3>Information about a file</h3>
  90. <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>
  91. <blockquote>
  92. <p>“url”: the publicly available upload url<br/>
  93. “direct_url”: the url to access the file directly<br/>
  94. “filename”: the (optionally generated) filename<br/>
  95. “expiry”: the unix timestamp at which the file will expire (0 if never)<br/>
  96. “size”: the size in bytes of the file<br/>
  97. “mimetype”: the guessed mimetype of the file<br/>
  98. “sha256sum”: the sha256sum of the file,</p>
  99. </blockquote>
  100. <p><strong>Example</strong></p>
  101. <pre><code>$ curl -H &#34;Accept: application/json&#34; {{ siteurl }}myphoto.jpg
  102. {&#34;expiry&#34;:&#34;0&#34;,&#34;filename&#34;:&#34;myphoto.jpg&#34;,&#34;mimetype&#34;:&#34;image/jpeg&#34;,&#34;sha256sum&#34;:&#34;...&#34;,&#34;size&#34;:&#34;...&#34;}</code></pre>
  103. </div>
  104. </div>
  105. </div>
  106. {% endblock %}