2018-07-04 22:46:51 +02:00
{{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 >
2019-02-17 22:44:37 +01:00
< td > Type< / td >
2018-07-04 22:46:51 +02:00
< td > Required< / td >
< td > Maximum Size< / td >
< td > Default< / td >
< td > Description< / td >
< / tr >
< tr >
< td > name< / td >
2019-02-17 22:44:37 +01:00
< td > string< / td >
2018-07-04 22:46:51 +02:00
< td > false< / td >
< td > 255 Characters< / td >
< td > Multipart file name< / td >
< td > Name of the file to upload< / td >
< / tr >
2019-02-17 22:44:37 +01:00
< tr >
< td > anonymous< / td >
< td > boolean< / td >
< td > false< / td >
< td > N/A< / td >
< td > false< / td >
< td > If the file should be uploaded anonymously< / td >
< / tr >
2018-08-06 23:33:03 +02:00
< tr >
< td > file< / td >
2019-02-17 22:44:37 +01:00
< td > multipart file< / td >
2018-08-06 23:33:03 +02:00
< td > true< / td >
2019-02-17 22:44:37 +01:00
< td > 10 000 000 000 Bytes< / td >
2018-08-06 23:33:03 +02:00
< td > none< / td >
< td > Multipart file to upload< / td >
< / tr >
2018-07-04 22:46:51 +02:00
< / 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",
2020-02-07 09:57:16 +01:00
"message": "The file you tried to upload is too large"
2018-07-04 22:46:51 +02:00
}< / 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 >
2018-11-06 22:19:57 +01:00
< p >
2020-02-07 09:57:16 +01:00
When '?download' is added to the URL the server will send an
attachment header instead of inline rendering, which causes the
browser to show a 'Save File' dialog.
< / p >
< p >
Warning: If a file is using too much bandwidth it can be rate
limited. The rate limit will be enabled if a file has ten times more
downloads than views. The owner of a file can always download it.
When a file is rate limited the user will need to fill out a captcha
in order to continue downloading the file. The captcha will only
appear on the file viewer page (pixeldrain.com/u/{id}). Rate
limiting has been added to prevent the spread of viruses and to stop
direct linking.
< / p >
< p >
Pixeldrain also includes a virus scanner. If a virus has been
detected in a file the user will also have to fill in a captcha to
download it.
2018-11-06 22:19:57 +01:00
< / p >
2018-07-04 22:46:51 +02:00
< 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 >
2018-11-06 22:19:57 +01:00
< tr >
< td > download< / td >
< td > false< / td >
< td > URL< / td >
< td > Sends file attachment instead of inline< / td >
< / tr >
2018-07-04 22:46:51 +02:00
< / table >
< h3 > Returns< / h3 >
2020-02-07 09:57:16 +01:00
< pre > HTTP 200: OK
The requested file.
< / pre >
< pre > HTTP 404: Not Found
{
"success": false,
"value": "not_found",
"message": "The entity you requested could not be found"
}
< / pre >
< pre > HTTP 403: Forbidden
{
"success": false,
"value": "file_rate_limited_captcha_required",
"message": "This file is using too much bandwidth. For anonymous downloads a captcha is required now. The captcha entry is available on the download page"
}
< / pre >
< pre > HTTP 403: Forbidden
{
"success": false,
"value": "virus_detected_captcha_required",
"message": "This file has been marked as malware by our scanning systems. To avoid infecting other systems through automated downloads we require you to enter a captcha. The captcha entry is available on the download page"
}
< / pre >
2018-07-04 22:46:51 +02:00
< / 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,
2020-02-07 09:57:16 +01:00
"id": "1234abcd",
2018-10-04 23:36:34 +02:00
"name": "screenshot.png",
2020-02-07 09:57:16 +01:00
"date_upload": 2020-02-04T18:34:05.706801Z,
"date_last_view": 2020-02-04T18:34:05.706801Z,
2018-10-04 23:36:34 +02:00
"size": 5694837, // Bytes
2018-07-04 22:46:51 +02:00
"views" 1234, // Amount of unique file views
2019-03-26 20:53:19 +01:00
"bandwidth_used": 1234567890, // Bytes
2018-07-04 22:46:51 +02:00
"mime_type" "image/png",
2020-02-07 09:57:16 +01:00
"thumbnail_href": "/file/1234abcd/thumbnail" // Link to a thumbnail of this file
2018-07-04 22:46:51 +02:00
}< / 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" >
2019-12-11 11:13:05 +01:00
< summary > < span class = "method" > GET< / span > /file/{id}/thumbnail?width=x& height=x< / summary >
2018-07-04 22:46:51 +02:00
< div >
< h3 > Description< / h3 >
< p >
2019-12-10 14:47:11 +01:00
Returns a PNG thumbnail image representing the file. The thumbnail
image will be 128x128 px by default. You can specify the width and
height with parameters in the URL. The width and height parameters
need to be a multiple of 16. So the allowed values are 16, 32, 48,
64, 80, 96, 112 and 128. If a thumbnail cannot be generated for the
file you will be redirected to a mime type image of 128x128 px.
2018-07-04 22:46:51 +02:00
< / 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 >
2019-12-10 14:47:11 +01:00
< tr >
< td > width< / td >
< td > false< / td >
< td > URL< / td >
< td > Width of the thumbnail image< / td >
< / tr >
< tr >
2019-12-11 11:13:05 +01:00
< td > height< / td >
2019-12-10 14:47:11 +01:00
< td > false< / td >
< td > URL< / td >
< td > Height of the thumbnail image< / td >
< / tr >
2018-07-04 22:46:51 +02:00
< / table >
< h3 > Returns< / h3 >
< p >
2019-12-10 14:47:11 +01:00
A PNG image if a thumbnail can be generated. If a thumbnail cannot
be generated you will get a 301 redirect to an image representing
the type of the file.
2018-07-04 22:46:51 +02:00
< / 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}}