Return file content

This function retrieves a file's content.

Important:

When you disable the File Storage role, the system disables this function.

Note:

JSON strings must be valid UTF-8. To retrieve a non-UTF-8 file via JSON, we recommend that you give ISO-8859-1 as from_charset and UTF-8 as to_charset, then decode the return payload’s content as UTF-8.

SecurityBasicAuth
Request
query Parameters
dir
required
string <path>

The file path to the directory that contains the selected file.

Example: dir=/home/user/public.html
file
required
string

The file to retrieve.

Example: file=example.html
from_charset
string
Default: "_DETECT_"

The file’s character encoding. This parameter defaults to _DETECT_, which indicates a request to detect the file’s character encoding.

Example: from_charset=_DETECT_
to_charset
string
Default: "_LOCALE_"

The output character encoding. This parameter defaults to _LOCALE_, which indicates a request to use the session locale’s character encoding.

Important:

Contexts that serialize the API response as JSON require this value to be utf-8 or US-ASCII. Behavior is undefined if the request indicates any other encoding.

Example: to_charset=_LOCALE_
update_html_document_encoding
integer
Default: 1

Whether to update the file's HTML document encoding.

  • 1 — Update the file's HTML document encoding.
  • 0 — Don't update the file's HTML encoding.
Enum: 0 1
Example: update_html_document_encoding=1
Responses
200

HTTP Request was successful.

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object
get/Fileman/get_file_content
Request samples
uapi --output=jsonpretty \
  --user=username \
  Fileman \
  get_file_content \
  dir='/home/user/public_html' \
  file='example.html'
Response samples
application/json
{
  • "apiversion": 3,
  • "func": "get_file_content",
  • "module": "Fileman",
  • "result": {
    • "data": {
      • "content": "`hi`",
      • "dir": "/home/user/public_html",
      • "filename": "example.html",
      • "from_char": "UTF-8",
      • "from_charset": null,
      • "path": "/home/user/public_html/example.html",
      • "to_char": "UTF-8",
      • "to_charset": null
      },
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}