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.

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