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.

138 lines
5.6 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. <p>Randomize the filename<br/>
  20. <code>Linx-Randomize: yes</code></p>
  21. <p>Specify a custom deletion key<br/>
  22. <code>Linx-Delete-Key: mysecret</code></p>
  23. <p>Specify an expiration time (in seconds)<br/>
  24. <code>Linx-Expiry: 60</code></p>
  25. <p>Get a json response<br/>
  26. <code>Accept: application/json</code></p>
  27. <p>The json response will then contain:</p>
  28. <blockquote>
  29. <p>“url”: the publicly available upload url<br/>
  30. “filename”: the (optionally generated) filename<br/>
  31. “delete_key”: the (optionally generated) deletion key,<br/>
  32. “expiry”: the unix timestamp at which the file will expire (0 if never)<br/>
  33. “size”: the size in bytes of the file<br/>
  34. “mimetype”: the guessed mimetype of the file<br/>
  35. “sha256sum”: the sha256sum of the file,</p>
  36. </blockquote>
  37. <p><strong>Examples</strong></p>
  38. <p>Uploading myphoto.jpg</p>
  39. {% if using_auth %}
  40. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -T myphoto.jpg {{ siteurl }}upload/
  41. {{ siteurl }}myphoto.jpg</code></pre>
  42. {% else %}
  43. <pre><code>$ curl -T myphoto.jpg {{ siteurl }}upload/
  44. {{ siteurl }}myphoto.jpg</code></pre>
  45. {% endif %}
  46. <p>Uploading myphoto.jpg with an expiry of 20 minutes</p>
  47. {% if using_auth %}
  48. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Linx-Expiry: 1200&#34; -T myphoto.jpg {{ siteurl }}upload/
  49. {{ siteurl }}myphoto.jpg</code></pre>
  50. {% else %}
  51. <pre><code>$ curl -H &#34;Linx-Expiry: 1200&#34; -T myphoto.jpg {{ siteurl }}upload/
  52. {{ siteurl }}myphoto.jpg</code></pre>
  53. {% endif %}
  54. <p>Uploading myphoto.jpg with a random filename and getting a json response:</p>
  55. {% if using_auth %}
  56. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Accept: application/json&#34; -H &#34;Linx-Randomize: yes&#34; -T myphoto.jpg {{ siteurl }}upload/
  57. {&#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;,
  58. &#34;sha256sum&#34;:&#34;...&#34;,&#34;size&#34;:&#34;...&#34;,&#34;url&#34;:&#34;{{ siteurl }}f34h4iu.jpg&#34;}</code></pre>
  59. {% else %}
  60. <pre><code>$ curl -H &#34;Accept: application/json&#34; -H &#34;Linx-Randomize: yes&#34; -T myphoto.jpg {{ siteurl }}upload/
  61. {&#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;,
  62. &#34;sha256sum&#34;:&#34;...&#34;,&#34;size&#34;:&#34;...&#34;,&#34;url&#34;:&#34;{{ siteurl }}f34h4iu.jpg&#34;}</code></pre>
  63. {% endif %}
  64. <h3>Overwriting a file</h3>
  65. <p>To overwrite a file you uploaded, simply provide the <code>Linx-Delete-Key</code> header with the original file's deletion key.</p>
  66. <p><strong>Example</p></strong>
  67. <p>To overwrite myphoto.jpg</p>
  68. {% if using_auth %}
  69. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Linx-Delete-Key: mysecret&#34; -T myphoto.jpg {{ siteurl }}upload/
  70. {{ siteurl }}myphoto.jpg</code></pre>
  71. {% else %}
  72. <pre><code>$ curl -H &#34;Linx-Delete-Key: mysecret&#34; -T myphoto.jpg {{ siteurl }}upload/
  73. {{ siteurl }}myphoto.jpg</code></pre>
  74. {% endif %}
  75. <h3>Deleting a file</h3>
  76. <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>
  77. <p><strong>Example</strong></p>
  78. <p>To delete myphoto.jpg</p>
  79. {% if using_auth %}
  80. <pre><code>$ curl -H &#34;Linx-Api-Key: mysecretkey&#34; -H &#34;Linx-Delete-Key: mysecret&#34; -X DELETE {{ siteurl }}myphoto.jpg
  81. DELETED</code></pre>
  82. {% else %}
  83. <pre><code>$ curl -H &#34;Linx-Delete-Key: mysecret&#34; -X DELETE {{ siteurl }}myphoto.jpg
  84. DELETED</code></pre>
  85. {% endif %}
  86. <h3>Information about a file</h3>
  87. <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>
  88. <blockquote>
  89. <p>“url”: the publicly available upload url<br/>
  90. “filename”: the (optionally generated) filename<br/>
  91. “expiry”: the unix timestamp at which the file will expire (0 if never)<br/>
  92. “size”: the size in bytes of the file<br/>
  93. “mimetype”: the guessed mimetype of the file<br/>
  94. “sha256sum”: the sha256sum of the file,</p>
  95. </blockquote>
  96. <p><strong>Example</strong></p>
  97. <pre><code>$ curl -H &#34;Accept: application/json&#34; {{ siteurl }}myphoto.jpg
  98. {&#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>
  99. </div>
  100. </div>
  101. </div>
  102. {% endblock %}