getFile(path, [includeMetadata]) Last updated: 17. Oct 2026

Gets a single file with its data and metadata.

See also: getFiles saveFile getJson fileExists GetFiles and Folders examples Path traversal

Parameters

Name Type Description
path string

Path of the file from the site root. If no file has that exact path, .hash, .html, /Index.hash, /Index.html and /Index are tried in that order — so a page or folder URL finds its file.

includeMetadata (optional) bool

Default true: the document's fields merged with Docly's file metadata — the same object as getFiles gives with mode "Full". false: only the document's own stored values.

Returns

An object — see getFiles for the fields (mode "Full"). null when no file is found or the path contains .. or a backslash. Throws if the path is empty.

No access check is made. A document in an encrypted folder can only be read after unlockFolder.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#{
    let file = docly.getFile("Test files/Example file.xlsx", true);
    var json = JSON.stringify(file);
    
    // Format indent and line breaks in JSON
    var pretty = docly.formatJson(json);
    
    // Remove empty lines
    var html = pretty.replace(chr(13), "");
    
    write(html);
}#

Output

The #JS code above produces the output shown below:
{
  "File": "0a4bdde7-e796-4e51-859b-2b7ba13c6f35.xlsx",
  "Title": "Example file.xlsx",
  "opendoc": "https://docly.net/DsAdeLq7IJ0CERkggJGIU7A?backurl=https%3a%2f%2fdevelopers.docly.net%2fJavaScript%2fFilesystem-functions%2fGetFile",
  "Url": "/Test-files/Example-file.xlsx",
  "FormName": "Uploaded File",
  "DoclyTypeId": 1,
  "DoclyTimestamp": "638071602624906438",
  "folderpath": "/Test files",
  "Tags": [],
  "LastModifiedBy": "r@dops.no",
  "filename": "Example file.xlsx",
  "filepath": "/Test files/Example file.xlsx",
  "fileschema": "Uploaded File",
  "file": true,
  "Guid": "sAdeLq7IJ0CERkggJGIU7A",
  "CreatedTime": "2022-12-20T19:09:09.9602572+01:00",
  "LastModified": "2022-12-20T19:11:02.4906438+01:00",
  "Filesize": 5710
}