FileController
extends ApiControllerBase
in package
This Controller extends ApiMutableModelControllerBase to create API endpoints for file uploading and downloading.
This API is accessiable at the following URL endpoint:
/api/dnscryptproxy/file
This class includes the following API endpoints:
upload
download
remove
Table of Contents
- downloadAction() : array<string|int, mixed>
- Calls the configd backend to retrive a pre-defined file, and return its contents.
- removeAction() : array<string|int, mixed>
- Allows removing a file using a specific pre-defined list of target files within the file system.
- uploadAction() : array<string|int, mixed>
- Allows uploading a file using a specific pre-defined list of destination files within the file system.
Methods
downloadAction()
Calls the configd backend to retrive a pre-defined file, and return its contents.
public
downloadAction(string $target) : array<string|int, mixed>
API endpoint:
/api/dnscryptproxy/file/get/settings.blocked_names_file_manual
Usage:
/api/dnscryptproxy/get/
This function only accepts specific $target variables to prevent user
manipulation through the API. This should be the field ID of the calling
object. It will then execute the appropriate configd command, and return
the output from that command. The output is evaluated on the return to
detect an error condition.
Parameters
- $target : string
-
The desired pre-defined target for the API.
Return values
array<string|int, mixed> —Array of the contents of the file.
removeAction()
Allows removing a file using a specific pre-defined list of target files within the file system.
public
removeAction() : array<string|int, mixed>
API endpoint:
/api/dnscryptproxy/file/remove
Usage:
/api/dnscryptproxy/file/remove
Usage (Javascript):
ajaxCall("{{ field['api']['remove'] }}",
{'field': '{{ field['id'] }}'},
function(data,status) {...
This function gets executed as part of clicking the remove button in the UI. After the user accepts to removing the file, this is called to remove the file from the file system.
The function exects a key-value pair to be set with the name field with
the value being the field ID of the desired field.
Tags
Return values
array<string|int, mixed> —Array of the contents of the file.
uploadAction()
Allows uploading a file using a specific pre-defined list of destination files within the file system.
public
uploadAction() : array<string|int, mixed>
API endpoint:
/api/dnscryptproxy/file/set
Usage:
/api/dnscryptproxy/set/settings.allowed_names_file_manual
This function only accepts specific $target variables to prevent user
manipulation through the API. It stores the file in a temporary location
and then a configd command executes a script which parses that file and
validates the contents, then copies that file to the pre-defined
destination.
Tags
Return values
array<string|int, mixed> —Array of the contents of the file.