The document file object

The document file object is used to access the content of a file associated with a document.


mimeType

Returns the MIME type of the file.

Syntax:

mimeType → string

Returns:

The MIME type of the file.

Example:

The following code iterates through the files associated with a document and prints the mime types:

<#list liquidsite.findDocument("Section1/doc1").files as file>
  Document file: ${file.name} (${file.size} bytes, ${file.mimeType})
</#list>

size

Returns the size of the file in bytes.

Syntax:

size → number

Returns:

The size of the file in bytes.

Example:

The following code iterates through the files associated with a document and prints the file sizes:

<#list liquidsite.findDocument("Section1/doc1").files as file>
  Document file: ${file.name} (${file.size} bytes, ${file.mimeType})
</#list>

created

Returns the file created date.

Syntax:

created → date

Returns:

The file created date.

Example:

The following code iterates through the files associated with a document and prints the creation dates:

<#list liquidsite.findDocument("Section1/doc1").files as file>
  Document file created: ${file.created}
</#list>

date

Returns the file revision date.

Syntax:

date → date

Returns:

The file revision date.

Example:

The following code iterates through the files associated with a document and prints the revision dates:

<#list liquidsite.findDocument("Section1/doc1").files as file>
  Document file revided: ${file.date}
</#list>

id

Returns the file id.

Syntax:

id → number

Returns:

The file id.

Example:

The following code iterates through the files associated with a document and prints the file ids:

<#list liquidsite.findDocument("Section1/doc1").files as file>
  Document file id: ${file.id}
</#list>

name

Returns the file name.

Syntax:

name → string

Returns:

The file name.

Example:

The following code iterates through the files associated with a document and prints the file names:

<#list liquidsite.findDocument("Section1/doc1").files as file>
  Document file: ${file.name} (${file.size} bytes, ${file.mimeType})
</#list>

lock

Returns the file lock object.

Syntax:

lock → lock object

Returns:

The file lock object.

Example:

The following code retrieves the lock from the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#assign fileLock = doc.files[0].lock>

online

Returns the file online flag.

Syntax:

online → boolean

Returns:

True if the file is online, false otherwise.

Example:

The following code retrieves the online flag from the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#assign fileOnline = doc.files[0].online>

parent

Returns the parent document of the file.

Syntax:

parent → document object

Returns:

The parent document under which the file is located.

Example:

The following code retrieves the document from the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#assign fileParent = doc.files[0].parent>
Behold, ${doc.id} and ${fileParent.id} are identical!

path

Returns the file path.

Syntax:

path → string

Returns:

The file path.

Example:

The following code outputs the file path from the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
The file path is ${doc.files[0].path}.

revision

Returns the file revision number.

Syntax:

revision → number

Returns:

The file revision number, or zero (0) if the file doesn't exist.

Example:

The following code outputs the revision from the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
The file revision is ${doc.files[0].revision}.

user

Returns the file revision author.

Syntax:

user → user object

Returns:

The file revision author, or an empty user if the file doesn't exist.

Example:

The following code stores the file revision user from the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#assign user = doc.files[0].user>

hasAccess

Checks if the current user has a specified access permission to the document file. The input permission types available are:

Syntax:

hasAccess(permission) → boolean

Parameters:

Returns:

True if the current user has the specified permission, or false otherwise.

Example:

The following code checks if the current user has write access to the first document file:

<#assign doc = liquidsite.findDocument("Section1/doc1")>
<#if doc.files[0].hasAccess("write")>
  The current user has write access.
</#if>