add api documentation for directory api
This commit is contained in:
@@ -17,9 +17,7 @@
|
|||||||
don't require an API key. All methods which delete or modify a
|
don't require an API key. All methods which delete or modify a
|
||||||
resource <strong>do</strong> require an API key.
|
resource <strong>do</strong> require an API key.
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
API keys can be obtained from the login API.
|
||||||
Though API keys have not been implemented yet, so you can't use
|
|
||||||
those methods yet.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Some JSON responses include fields which end in "_href" (some
|
Some JSON responses include fields which end in "_href" (some
|
||||||
@@ -46,6 +44,11 @@
|
|||||||
{{template "api-list-post"}}
|
{{template "api-list-post"}}
|
||||||
{{template "api-list-get"}}
|
{{template "api-list-get"}}
|
||||||
|
|
||||||
|
<h2>Directory Methods</h2>
|
||||||
|
{{template "api-directory-path-post"}}
|
||||||
|
{{template "api-directory-path-get"}}
|
||||||
|
{{template "api-directory-path-delete"}}
|
||||||
|
|
||||||
{{template "footer"}}
|
{{template "footer"}}
|
||||||
</div>
|
</div>
|
||||||
{{template "analytics"}}
|
{{template "analytics"}}
|
||||||
|
155
res/template/fragments/api/directory.html
Normal file
155
res/template/fragments/api/directory.html
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
{{define "api-directory-path-post"}}
|
||||||
|
<details class="api_doc_details request_post">
|
||||||
|
<summary><span class="method">POST</span>/directory/{path}</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Creates a new directory or uploads a file to an existing directory.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>type</td>
|
||||||
|
<td>Form Values</td>
|
||||||
|
<td>The type of node to create, can either be 'directory', or 'file'</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>name</td>
|
||||||
|
<td>Form Values</td>
|
||||||
|
<td>
|
||||||
|
Name of the directory to create, or of file to create. Not
|
||||||
|
required if 'type' is 'file'
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>file</td>
|
||||||
|
<td>Form Values</td>
|
||||||
|
<td>
|
||||||
|
Multipart file to upload to the directory. Will be ignored
|
||||||
|
if 'type' is 'directory'
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"id": "abc123" // ID of the newly uploaded file
|
||||||
|
}</pre>
|
||||||
|
todo
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-directory-path-get"}}
|
||||||
|
<details class="api_doc_details request_get">
|
||||||
|
<summary><span class="method">GET</span>/directory/{path}</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Returns information about the requested path.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>path</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>Path to the directory or file to request</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>download</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>
|
||||||
|
If the URL paramater '?download' is passed the requested
|
||||||
|
file will be downloaded (if it is a file)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<h4>When the requested entity is a directory:</h4>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"name": "some dir",
|
||||||
|
"path": "/some dir",
|
||||||
|
"type": "directory",
|
||||||
|
"child_directories": [
|
||||||
|
{
|
||||||
|
"name": "some other directory",
|
||||||
|
"path": "/some dir/some other directory"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"child_files": [
|
||||||
|
{
|
||||||
|
"name": "11. Lenny Kravitz - Fly away.ogg",
|
||||||
|
"path": "/some dir/11. Lenny Kravitz - Fly away.ogg"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}</pre>
|
||||||
|
<h4>When the requested entity is a file:</h4>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"name": "11. Lenny Kravitz - Fly away.ogg",
|
||||||
|
"path": "/some dir/11. Lenny Kravitz - Fly away.ogg",
|
||||||
|
"type": "file",
|
||||||
|
"file_info": {
|
||||||
|
"success": true,
|
||||||
|
"id": "Jf_u5TI9",
|
||||||
|
"file_name": "11. Lenny Kravitz - Fly away.ogg",
|
||||||
|
"date_upload": "2018-07-04T22:24:48Z",
|
||||||
|
"date_last_view": "2018-07-04T22:24:48Z",
|
||||||
|
"file_size": 9757269,
|
||||||
|
"views": 0,
|
||||||
|
"mime_type": "application/ogg",
|
||||||
|
"thumbnail_href": "/file/Jf_u5TI9/thumbnail"
|
||||||
|
}
|
||||||
|
}</pre>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-directory-path-delete"}}
|
||||||
|
<details class="api_doc_details request_delete">
|
||||||
|
<summary><span class="method">DELETE</span>/directory/{path}</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Deletes a filesystem node.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>path</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>Path of the entity to delete</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}</pre>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
@@ -1,51 +0,0 @@
|
|||||||
{{define "api-file-id-delete"}}
|
|
||||||
<details th:fragment="details" class="api_doc_details request_delete">
|
|
||||||
<summary><span class="method">DELETE</span>/file/{id}</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Deletes a file. Only works when the users owns the file.
|
|
||||||
</p>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Param</td>
|
|
||||||
<td>Required</td>
|
|
||||||
<td>Location</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>id</td>
|
|
||||||
<td>true</td>
|
|
||||||
<td>URL</td>
|
|
||||||
<td>ID of the file to delete</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<pre>HTTP 200: OK
|
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"value": "file_deleted",
|
|
||||||
"message": "The file has been deleted."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 404: Not Found
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "file_not_found",
|
|
||||||
"message": "File ID was not found in the database."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 401: Unauthorized
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "unauthorized",
|
|
||||||
"message": "You are not logged in."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 403: Forbidden
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "forbidden",
|
|
||||||
"message": "This is not your file."
|
|
||||||
}</pre>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
@@ -1,13 +0,0 @@
|
|||||||
{{define "api-file-id-download-get"}}
|
|
||||||
<details th:fragment="details" class="api_doc_details request_get">
|
|
||||||
<summary><span class="method">GET</span>/file/{id}/download</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Same as GET /file/{id}, but with File Transfer HTTP
|
|
||||||
headers. Will trigger a save file dialog when opened in
|
|
||||||
a web browser. Also supports byte range requests.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
@@ -1,29 +0,0 @@
|
|||||||
{{define "api-file-id-get"}}
|
|
||||||
<details th:fragment="details" class="api_doc_details request_get">
|
|
||||||
<summary><span class="method">GET</span>/file/{id}</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Returns the full file associated with the ID. Supports
|
|
||||||
byte range requests.
|
|
||||||
</p>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Param</td>
|
|
||||||
<td>Required</td>
|
|
||||||
<td>Location</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>id</td>
|
|
||||||
<td>true</td>
|
|
||||||
<td>URL</td>
|
|
||||||
<td>ID of the file to request</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Returns</h3>
|
|
||||||
A file output stream.
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
@@ -1,49 +0,0 @@
|
|||||||
{{define "api-file-id-info-get"}}
|
|
||||||
<details th:fragment="details" class="api_doc_details request_get">
|
|
||||||
<summary><span class="method">GET</span>/file/{id}/info</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Returns information about one or more files.
|
|
||||||
You can also put a comma separated list of file IDs in
|
|
||||||
the URL and it will return an array of file info,
|
|
||||||
instead of a single object.
|
|
||||||
</p>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Param</td>
|
|
||||||
<td>Required</td>
|
|
||||||
<td>Location</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>id</td>
|
|
||||||
<td>true</td>
|
|
||||||
<td>URL</td>
|
|
||||||
<td>ID(s) of the file</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<pre>HTTP 200: OK
|
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"id": "123abc",
|
|
||||||
"file_name": "screenshot.png",
|
|
||||||
"date_upload": 1485894987, // Timestamp
|
|
||||||
"date_last_view": 1485894987, // Timestamp
|
|
||||||
"file_size": 5694837, // Bytes
|
|
||||||
"views" 1234, // Amount of unique file views
|
|
||||||
"mime_type" "image/png",
|
|
||||||
"description": "File description",
|
|
||||||
"mime_image": "http://pixeldra.in/res/img/mime/image-png.png", // Image associated with the mime type
|
|
||||||
"thumbnail": "http://pixeldra.in/api/thumbnail/123abc" // Link to a thumbnail of this file
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 404: Not Found
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "file_not_found"
|
|
||||||
}</pre>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
@@ -1,34 +0,0 @@
|
|||||||
{{define "api-file-id-thumbnail-get"}}
|
|
||||||
<details th:fragment="details" class="api_doc_details request_get">
|
|
||||||
<summary><span class="method">GET</span>/file/{id}/thumbnail</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Returns a PNG thumbnail image representing the file.
|
|
||||||
The thumbnail is always 100*100 px. If the source file
|
|
||||||
is parsable by imagemagick the thumbnail will be
|
|
||||||
generated from the file, if not it will be a generic
|
|
||||||
mime type icon.
|
|
||||||
</p>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Param</td>
|
|
||||||
<td>Required</td>
|
|
||||||
<td>Location</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>id</td>
|
|
||||||
<td>true</td>
|
|
||||||
<td>URL</td>
|
|
||||||
<td>ID of the file to get a thumbnail for</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<p>
|
|
||||||
A PNG image of 100*100 px.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
@@ -1,73 +0,0 @@
|
|||||||
{{define "api-file-post"}}
|
|
||||||
<details th:fragment="details" class="api_doc_details request_post">
|
|
||||||
<summary><span class="method">POST</span>/file</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Upload a file.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Param</td>
|
|
||||||
<td>Required</td>
|
|
||||||
<td>Maximum Size</td>
|
|
||||||
<td>Default</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>file</td>
|
|
||||||
<td>true</td>
|
|
||||||
<td>5 000 000 000 Bytes</td>
|
|
||||||
<td>none</td>
|
|
||||||
<td>Multipart file to upload</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>name</td>
|
|
||||||
<td>false</td>
|
|
||||||
<td>255 Characters</td>
|
|
||||||
<td>Multipart file name</td>
|
|
||||||
<td>Name of the file to upload</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<pre>HTTP 200: OK
|
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"id": "abc123" // ID of the newly uploaded file
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 422: Unprocessable Entity
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "no_file",
|
|
||||||
"message": "The file does not exist or is empty."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 500: Internal Server Error
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "internal",
|
|
||||||
"message": "An internal server error occurred."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 413: Payload Too Large
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "file_too_large",
|
|
||||||
"message": "The file you tried to upload is too large. Max 5000 MB allowed."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 500: Internal Server Error
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "writing",
|
|
||||||
"message": "Something went wrong while writing the file to disk, the server may be out of storage space."
|
|
||||||
}</pre>
|
|
||||||
<pre>HTTP 413: Payload Too Large
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "name_too_long",
|
|
||||||
"message": "File Name is too long, Max 255 characters allowed."
|
|
||||||
}</pre>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
249
res/template/fragments/api/file.html
Normal file
249
res/template/fragments/api/file.html
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
{{define "api-file-post"}}
|
||||||
|
<details class="api_doc_details request_post">
|
||||||
|
<summary><span class="method">POST</span>/file</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Upload a file.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Maximum Size</td>
|
||||||
|
<td>Default</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>file</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>5 000 000 000 Bytes</td>
|
||||||
|
<td>none</td>
|
||||||
|
<td>Multipart file to upload</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>name</td>
|
||||||
|
<td>false</td>
|
||||||
|
<td>255 Characters</td>
|
||||||
|
<td>Multipart file name</td>
|
||||||
|
<td>Name of the file to upload</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"id": "abc123" // ID of the newly uploaded file
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 422: Unprocessable Entity
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "no_file",
|
||||||
|
"message": "The file does not exist or is empty."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 500: Internal Server Error
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "internal",
|
||||||
|
"message": "An internal server error occurred."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 413: Payload Too Large
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "file_too_large",
|
||||||
|
"message": "The file you tried to upload is too large. Max 5000 MB allowed."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 500: Internal Server Error
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "writing",
|
||||||
|
"message": "Something went wrong while writing the file to disk, the server may be out of storage space."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 413: Payload Too Large
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "name_too_long",
|
||||||
|
"message": "File Name is too long, Max 255 characters allowed."
|
||||||
|
}</pre>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-file-id-get"}}
|
||||||
|
<details class="api_doc_details request_get">
|
||||||
|
<summary><span class="method">GET</span>/file/{id}</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Returns the full file associated with the ID. Supports
|
||||||
|
byte range requests.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>id</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>ID of the file to request</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
A file output stream.
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-file-id-download-get"}}
|
||||||
|
<details class="api_doc_details request_get">
|
||||||
|
<summary><span class="method">GET</span>/file/{id}/download</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Same as GET /file/{id}, but with File Transfer HTTP
|
||||||
|
headers. Will trigger a save file dialog when opened in
|
||||||
|
a web browser. Also supports byte range requests.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-file-id-info-get"}}
|
||||||
|
<details class="api_doc_details request_get">
|
||||||
|
<summary><span class="method">GET</span>/file/{id}/info</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Returns information about one or more files.
|
||||||
|
You can also put a comma separated list of file IDs in
|
||||||
|
the URL and it will return an array of file info,
|
||||||
|
instead of a single object.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>id</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>ID(s) of the file</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"id": "123abc",
|
||||||
|
"file_name": "screenshot.png",
|
||||||
|
"date_upload": 1485894987, // Timestamp
|
||||||
|
"date_last_view": 1485894987, // Timestamp
|
||||||
|
"file_size": 5694837, // Bytes
|
||||||
|
"views" 1234, // Amount of unique file views
|
||||||
|
"mime_type" "image/png",
|
||||||
|
"description": "File description",
|
||||||
|
"mime_image": "http://pixeldra.in/res/img/mime/image-png.png", // Image associated with the mime type
|
||||||
|
"thumbnail": "http://pixeldra.in/api/thumbnail/123abc" // Link to a thumbnail of this file
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 404: Not Found
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "file_not_found"
|
||||||
|
}</pre>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-file-id-thumbnail-get"}}
|
||||||
|
<details class="api_doc_details request_get">
|
||||||
|
<summary><span class="method">GET</span>/file/{id}/thumbnail</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Returns a PNG thumbnail image representing the file.
|
||||||
|
The thumbnail is always 100*100 px. If the source file
|
||||||
|
is parsable by imagemagick the thumbnail will be
|
||||||
|
generated from the file, if not it will be a generic
|
||||||
|
mime type icon.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>id</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>ID of the file to get a thumbnail for</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<p>
|
||||||
|
A PNG image of 100*100 px.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
||||||
|
{{define "api-file-id-delete"}}
|
||||||
|
<details class="api_doc_details request_delete">
|
||||||
|
<summary><span class="method">DELETE</span>/file/{id}</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Deletes a file. Only works when the users owns the file.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>id</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>ID of the file to delete</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"value": "file_deleted",
|
||||||
|
"message": "The file has been deleted."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 404: Not Found
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "file_not_found",
|
||||||
|
"message": "File ID was not found in the database."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 401: Unauthorized
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "unauthorized",
|
||||||
|
"message": "You are not logged in."
|
||||||
|
}</pre>
|
||||||
|
<pre>HTTP 403: Forbidden
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "forbidden",
|
||||||
|
"message": "This is not your file."
|
||||||
|
}</pre>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
@@ -1,78 +0,0 @@
|
|||||||
{{define "api-list-get"}}
|
|
||||||
<details class="api_doc_details request_get">
|
|
||||||
<summary><span class="method">GET</span>/list/{id}</summary>
|
|
||||||
<div>
|
|
||||||
<h3>Description</h3>
|
|
||||||
<p>
|
|
||||||
Returns information about a file list and the files in it.
|
|
||||||
</p>
|
|
||||||
<h3>Parameters</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Param</td>
|
|
||||||
<td>Required</td>
|
|
||||||
<td>Location</td>
|
|
||||||
<td>Description</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>id</td>
|
|
||||||
<td>true</td>
|
|
||||||
<td>URL</td>
|
|
||||||
<td>ID of the list</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h3>Returns</h3>
|
|
||||||
<p>
|
|
||||||
The API will return some basic information about every file.
|
|
||||||
Every file also has a "detail_href" field which contains a URL
|
|
||||||
to the info API of the file. Follow that link to get more
|
|
||||||
information about the file like size, checksum, mime type, etc.
|
|
||||||
The address is relative to the API URL and should be appended to
|
|
||||||
the end.
|
|
||||||
</p>
|
|
||||||
<pre>HTTP 200: OK
|
|
||||||
{
|
|
||||||
"success": true,
|
|
||||||
"id": "L8bhwx",
|
|
||||||
"title": "Rust in Peace",
|
|
||||||
"date_created": 1513033315,
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"detail_href": "/file/_SqVWi/info",
|
|
||||||
"id": "_SqVWi",
|
|
||||||
"file_name": "01 Holy Wars... The Punishment Due.mp3",
|
|
||||||
"description": "",
|
|
||||||
"date_created": 1513033304,
|
|
||||||
"date_last_view": 1513033304,
|
|
||||||
"list_description": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"detail_href": "/file/RKwgZb/info",
|
|
||||||
"id": "RKwgZb",
|
|
||||||
"file_name": "02 Hangar 18.mp3",
|
|
||||||
"description": "",
|
|
||||||
"date_created": 1513033304,
|
|
||||||
"date_last_view": 1513033304,
|
|
||||||
"list_description": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"detail_href": "/file/DRaL_e/info",
|
|
||||||
"id": "DRaL_e",
|
|
||||||
"file_name": "03 Take No Prisoners.mp3",
|
|
||||||
"description": "",
|
|
||||||
"date_created": 1513033304,
|
|
||||||
"date_last_view": 1513033304,
|
|
||||||
"list_description": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
<pre>HTTP 404: Not Found
|
|
||||||
{
|
|
||||||
"success": false,
|
|
||||||
"value": "list_not_found",
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
{{end}}
|
|
@@ -4,7 +4,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h3>Description</h3>
|
<h3>Description</h3>
|
||||||
<p>
|
<p>
|
||||||
Creates a list of files that can be viewed together on the file
|
Creates a list of files that can be viewed together on the file
|
||||||
viewer page.
|
viewer page.
|
||||||
</p>
|
</p>
|
||||||
<h3>Parameters</h3>
|
<h3>Parameters</h3>
|
||||||
@@ -81,4 +81,82 @@
|
|||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{define "api-list-get"}}
|
||||||
|
<details class="api_doc_details request_get">
|
||||||
|
<summary><span class="method">GET</span>/list/{id}</summary>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>
|
||||||
|
Returns information about a file list and the files in it.
|
||||||
|
</p>
|
||||||
|
<h3>Parameters</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Param</td>
|
||||||
|
<td>Required</td>
|
||||||
|
<td>Location</td>
|
||||||
|
<td>Description</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>id</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>ID of the list</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3>Returns</h3>
|
||||||
|
<p>
|
||||||
|
The API will return some basic information about every file.
|
||||||
|
Every file also has a "detail_href" field which contains a URL
|
||||||
|
to the info API of the file. Follow that link to get more
|
||||||
|
information about the file like size, checksum, mime type, etc.
|
||||||
|
The address is relative to the API URL and should be appended to
|
||||||
|
the end.
|
||||||
|
</p>
|
||||||
|
<pre>HTTP 200: OK
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"id": "L8bhwx",
|
||||||
|
"title": "Rust in Peace",
|
||||||
|
"date_created": 1513033315,
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"detail_href": "/file/_SqVWi/info",
|
||||||
|
"id": "_SqVWi",
|
||||||
|
"file_name": "01 Holy Wars... The Punishment Due.mp3",
|
||||||
|
"description": "",
|
||||||
|
"date_created": 1513033304,
|
||||||
|
"date_last_view": 1513033304,
|
||||||
|
"list_description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"detail_href": "/file/RKwgZb/info",
|
||||||
|
"id": "RKwgZb",
|
||||||
|
"file_name": "02 Hangar 18.mp3",
|
||||||
|
"description": "",
|
||||||
|
"date_created": 1513033304,
|
||||||
|
"date_last_view": 1513033304,
|
||||||
|
"list_description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"detail_href": "/file/DRaL_e/info",
|
||||||
|
"id": "DRaL_e",
|
||||||
|
"file_name": "03 Take No Prisoners.mp3",
|
||||||
|
"description": "",
|
||||||
|
"date_created": 1513033304,
|
||||||
|
"date_last_view": 1513033304,
|
||||||
|
"list_description": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
<pre>HTTP 404: Not Found
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"value": "list_not_found",
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
{{end}}
|
Reference in New Issue
Block a user