Filesystem functions

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

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

Unlocks an encrypted folder for the duration of the current script execution. After unlocking, all file operations (saveFile, downloadEmbedded, saveEmbeddedFile, etc.) will transparently encrypt and decrypt content in this folder.

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)

Check whether a file exists or not within the site.

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

Check whether a folder exists or not within your site.

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

Creates a folder (also parent folders if missing) from specified path.

de­lete­Fil­e(filePath)

Deletes a specified file.

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(folderPath, properties)
va­lida­teF­ile­name(filename)

Validates that a filename contains only allowed characters.

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

This function extracts images encoded in base64 from an HTML string. It then converts these images to a more storage-efficient format by saving them separately as embedded files. The revised HTML string will reference these images using a Content ID (CID) mechanism, similar to how images are referenced in email attachments.

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 storage-efficient format by saving them as embedded files within the document. The revised HTML will reference these images using a Content ID (CID) mechanism, similar to how images are referenced in email attachments.

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.

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

Saves an embedded file to the properties of an existing Docly folder.
Note that embedded files that are not referenced by a field in the folder properties document will be automatically deleted.

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

Checks if the current user has access to open the specified file or folder in Docly. Only applicable for sites with authentication enabled.

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

Checks if the current user has access to modify specified file or folder in Docly. Only applicable for sites with authentication enabled.

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

Checks if the current user has website (view) access to the specified file or folder. Only applicable for sites with authentication enabled.

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 size of an embedded file (image or file upload) 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(filepath, metadata)

Gets information about a specific file.

getJ­son(filepath)

Loads a JSON file and returns the content as an object.

link­File(embeddedId, filename)

Creates the link to an embedded file within the current document. This function is only available for display templates for document schemas.

list­File­s(path, options)

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

list­Fol­de­rs(path, searchPattern, recursive, includeCounters)

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

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

Creates a link to an image within a document. Only works from site display templates for documents.

Ima­ge sca­lin­g

Read about the different scaling modes here.

loa­dEx­cel(filename, column, row, sheet)

Loads data from Excel file into an array of objects.

mo­veFi­le(filePath, toPath)

Moves a file from one folder to another, and renames it if the name part of the path is changed.

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

Moves a folder within your site.

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

Renames a file.

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 automatically deleted.

patch­Fil­e(filePath, patchData)

Updates/patches an existing file in Docly document according to specified schema. The patch is merged with existing data.

sa­veFi­le(filePath, data, schema, ensurePath)

Saves a file to 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 a standardized format.
For more advanced document saving with custom schemas, consider using the "SaveFile" function.

logJ­son(filePath, data)

Creates a new JSON array file or adds a new item to the existing array in the file. This function works as a log, maintaining an array of events with automatic timestamping. If the log file path ends with '/', the current date (yyyyMMdd) will be automatically appended as the filename. The log automatically limits entries to prevent excessive file size.