Filesystem functions

Functions to link files and images from Docly to your web content.

get­File­s(path, options)

Gets a list of files from folder / optionally recursively from subfolders.

get­Fol­der(path)

Returns information about a folder by given path.

fi­leE­xist­s(filePath)

Checks whether a file exists in the site, including files the site inherits from the app (publish template) it runs from. Available in…

fol­derE­xi­st­s(path)

Checks whether a folder exists in the site, including folders the site inherits from the app (publish template) it runs from. Only…

crea­teFo­lde­r(folderPath, folderType)

Creates a folder from the specified path, including any missing parent folders. Folders that already exist are left as they are.

de­lete­Fil­e(filePath)

Deletes a specified file. The call runs as the user who published the site, not as the visitor. Check the visitor's own rights with…

de­lete­Fol­d­er(folderPath)

Deletes a specified folder.

get­Fol­der­Prop­s(folderPath)

Get a specified folders current properties.

sa­veFol­de­rP­rop­s(path, values, options)

Saves the properties of a folder — the data in its folder properties document. The call runs as the user who published the site, not as the…

va­lida­teF­ile­name(filename)

Validates that a filename contains only allowed characters.

ext­ract­Ba­se6­4Ima­ge­s(html)

Extracts base64-encoded images from an HTML string and replaces each one with a Content ID (cid:) reference, the way images are referenced…

ext­rac­tAn­d­Em­bed­Base­64I­mage­s(filePath, propertyFilter)

This function extracts images encoded in base64 from HTML properties of a document. It then converts these images to a more…

crea­teZi­p(content)

Creates a ZIP-file and adds specified files and folders to it.

ge­tEm­bed­de­dFi­le(path, id)

Get bytes of an embedded file (image or file upload) in a specific document.

Inc­lude(path, template)

Include a file or template into another page. include2 is an internal variant used while rendering included documents — do not call it…

sa­veEm­bed­d­ed­Fol­der­Fi­le(folderPath, embeddedFilename, data)

Saves an embedded file to the properties document of an existing folder. The folder must already have a properties document — create one…

al­low­Rea­d(path, username)

Checks whether the logged-in visitor, or a given user, may open the specified file or folder in Docly. For a folder this is Browse access,…

al­low­Modi­f­y(path, username)

Checks whether the logged-in visitor, or a given user, may modify the specified file or folder in Docly. Only meaningful on sites with…

al­low­Visi­t(path, username)

Checks whether the logged-in visitor, or a given user, has website (Visit) access to the specified file or folder. Only meaningful on sites…

ge­tEm­bed­de­dFi­leSi­ze(path, id)

Get the size of an embedded file (image or file upload) in a specific document.

get­Fol­der­s(path, options)

Gets a list of all subfolders below a specific folder.

ge­tEm­bed­de­dText­Fil­e(path, id, encoding)

Get the text content of an embedded file in a specific document.

ge­tEm­bed­de­dFol­der­Fi­le(folderPath, embeddedFilename)

Retrieves embedded file content from a folder's property file (.docly) by extracting and decoding the specified file data.

get­File(path, includeMetadata)

Gets a single file with its data and metadata.

getJ­son(filepath)

Loads a document and returns its stored values as an object. Works on any document — a .json code file, or a schema document (you get its…

link­File(fileObject, embeddedId, filename)

Creates the link to an embedded file within a document. Available in every #JS context — display templates, .hash pages, master pages and…

list­File­s(path, options)

The fastest function to retrieve a list of files from a specific path.

list­Fol­de­rs(path, options)

The fastest function to retrieve a list of folders from a specific path.

lin­kIma­ge(fileObject, embeddedId, width, height, mode, filename)

Creates a link to an image within a document, building a WxHxM image URL. Available in every #JS context — display templates, .hash pages,…

Ima­ge sca­lin­g

How scaled image URLs work, which sizes a site accepts (images.sizePolicy), and the scaling modes.

loa­dEx­cel(file, startCol, startRow, sheetNo)

Loads data from Excel file into an array of objects.

Ima­ge out­put for­mat­s

Docly can deliver modern image formats (WebP / AVIF) with better compression via scaleImage and the site-wide default format.

mo­veFi­le(filePath, toPath)

Moves a file into another folder. The file keeps its name — use renameFile to change the name.

mo­veFol­de­r(folderPath, destinationPath)

Moves a folder to a new location within your site.

re­name­Fil­e(filePath, newName)

Renames an existing file while keeping it in the same folder. The file is identified by its full path, and only the filename is changed.

sa­veEm­bed­d­ed­File(filePath, embeddedId, data)

Saves an embedded file to an existing Docly document. Note that embedded files that are not referenced by a field in the document will be…

re­name­Fol­d­er(folderPath, newName)

Renames an existing folder without moving it. The folder remains in its current parent directory but receives a new name.

patch­Fil­e(path, patch)

Merges the given properties into an existing document and saves it. The merge is shallow: each top-level property in the patch replaces the…

sa­veFi­le(filePath, data, options)

Saves a file to a Docly document according to specified schema. Overwrites if it already exists.

sa­veJ­son(filePath, data, ensurePath)

Saves data as a JSON file to Docly with specified content stringified to JSON format. This function is ideal for storing structured data in…

logJ­son(filePath, data)

Appends an entry to a JSON log file — a file holding a JSON array — and creates the file if it does not exist. If the path ends with '/',…

un­lock­Fol­d­er(path, encryptionKey)

Unlocks an encrypted folder for the current request. After unlocking, file operations (getFile, saveFile, downloadEmbedded,…

get­Tag­s(path)

Returns the tags stored on a document. Tags share their storage with the full text search index, so they are always stored — and returned —…

add­Tag(path, tag)

Adds a tag to a document without touching the tags that are already there. Only the missing tag is written, so two scripts tagging the same…

re­move­Tag(path, tag)

Removes a tag from a document without touching its other tags. The counterpart of addTag, and…

ge­tAll­Tag­s(path, options)

Returns every distinct tag in use in a folder — the list you need to fill a tag picker, an autocomplete or a filter menu. The values it…

get­File­na­me­s(path, options)

Returns the names of the files in a folder — a lighter alternative to listFiles when the names are all you need. Only the folder itself is…

get­Page­s(path, options)

Returns the pages in a folder, for building menus and listings: one entry for each subfolder that has an index page, followed by the files.…

loa­d(file)

Loads a file from the site, runs the #JS code it contains and returns the result as text.

dri­ve.­get­F­ile­s(path, options)

Lists every file below a folder the way it appears on a mapped Docly drive — with the file names and extensions a drive or an export uses.…

dri­ve.­get­F­ile(path)

Returns the content of a file the way it appears on a mapped Docly drive. Called as drive.getFile(...).