Sign Up
Loading...

Managing Files

Watch the walkthrough

Browse all video tutorials

Twidget offers a set of commands to manipulate files in your file store. Below are the descriptions and usage of each command to help you understand how to utilize them effectively.

For CSV, ZIP archives and temporary download links, see Advanced file commands.

Get File

Retrieve a file via file path.

Inputs:

  • path: The file path to retrieve the file from.

  • get_bytes (Include bytes): Request the actual file contents when a following command needs them. Bytes are not loaded automatically just because a path is present. Keep reads bounded and use an uploaded or explicitly read FILE value for image, spreadsheet, PDF and connector commands that require file contents.

Outputs:

  • filename: The name of the file.

  • path: The path of the file.

  • parent_path: The parent directory path.

  • file_size: The size of the file in bytes.

  • is_directory: Boolean indicating if it is a directory.

  • is_file: Boolean indicating if it is a file.

  • is_root: Boolean indicating if it is the root directory.

  • is_multi_part_file: Boolean indicating if it is a multi-part file.

  • bytes: File contents only when requested with Include bytes, subject to runtime file-size limits.

Copy File

Copy a provided file to another file path.

Inputs:

  • file: The file you want to copy.

  • copy_path: The destination path where the file should be copied.

Outputs:

  • filename: The name of the file.

  • path: The path of the file.

  • parent_path: The parent directory path.

  • file_size: The size of the file in bytes.

  • is_directory: Boolean indicating if it is a directory.

  • is_file: Boolean indicating if it is a file.

  • is_root: Boolean indicating if it is the root directory.

  • is_multi_part_file: Boolean indicating if it is a multi-part file.

  • bytes: The bytes of the file.

Delete File

Delete the provided file.

Inputs:

  • file: The file you want to delete.

Outputs:

  • A boolean indicating if the file deletion was successful.

File Size

Get the size of a file.

Inputs:

  • file: The file whose size you want to retrieve.

Outputs:

  • The size of the file in bytes.

Get Parent Path

Get the parent path of the provided file.

Inputs:

  • file: The file whose parent path you want to retrieve.

Outputs:

  • The parent directory path.

Parent File

Get the parent file/folder of the provided file.

Inputs:

  • file: The file whose parent file/folder you want to retrieve.

Outputs:

  • filename: The name of the file.

  • path: The path of the file.

  • parent_path: The parent directory path.

  • file_size: The size of the file in bytes.

  • is_directory: Boolean indicating if it is a directory.

  • is_file: Boolean indicating if it is a file.

  • is_root: Boolean indicating if it is the root directory.

  • is_multi_part_file: Boolean indicating if it is a multi-part file.

  • bytes: The bytes of the file.

List Files

List files in the specified folder.

Inputs:

  • file: The folder whose files you want to list.

Outputs:

  • A list of files with fields:

    • filename: The name of the file.

    • path: The path of the file.

    • parent_path: The parent directory path.

    • file_size: The size of the file in bytes.

    • is_directory: Boolean indicating if it is a directory.

    • is_file: Boolean indicating if it is a file.

    • is_root: Boolean indicating if it is the root directory.

    • is_multi_part_file: Boolean indicating if it is a multi-part file.

    • bytes: The bytes of the file.

Make Folder

Create a new folder at the specified path.

Inputs:

  • path: The path where you want to create the new folder.

Outputs:

  • A boolean indicating if the folder creation was successful.

Rename

Rename the specified file or folder.

Inputs:

  • file: The file or folder you want to rename.

  • path: The new name for the file or folder.

Outputs:

  • A boolean indicating if the rename was successful.

Upload File

Write data to a file in the file store.

Inputs:

  • path: The path where you want to write the file.

  • data: The data to write to the file.

Outputs:

  • filename: The name of the file.

  • path: The path of the file.

  • parent_path: The parent directory path.

  • file_size: The size of the file in bytes.

  • is_directory: Boolean indicating if it is a directory.

  • is_file: Boolean indicating if it is a file.

  • is_root: Boolean indicating if it is the root directory.

  • is_multi_part_file: Boolean indicating if it is a multi-part file.

  • bytes: The bytes of the file.

Append to File

Append data to a file in the file store.

Inputs:

  • file: The file to append the data to.

  • data: The data to append.

Outputs:

  • None

Read Text File

Read the text content of the specified file.

Inputs:

  • file: The file whose text content you want to read.

Outputs:

  • The text content of the file.

Is Folder

Check if the provided file is a folder.

Inputs:

  • file: The file to check.

Outputs:

  • A boolean indicating if it is a folder.

Is File

Check if the provided file is a file.

Inputs:

  • file: The file to check.

Outputs:

  • A boolean indicating if it is a file.

File Exists

Check if the provided file exists.

Inputs:

  • path: The path of the file to check.

Outputs:

  • A boolean indicating if the file exists.

Is Root

Check if the provided path is the root of the system.

Inputs:

  • file: The file or path to check.

Outputs:

  • A boolean indicating if it is the root directory.

Related Topics

Page Security

Use these commands in page workflows to check reCAPTCHA before accepting a form submission. Configure your keys first; see [Page Settings](/docs/pages/page-settings) and the existing [reCAPTCHA guide](/docs/pages/recaptcha). Generate reCAPTCHA token. Generates a token for the current interaction. Th...

Advanced file commands

Prepare CSV downloads, work with small ZIP archives and share a temporary download link from an endpoint, server function or event. Find these commands under File Manager when adding a command. Use the usual variable selector and Return as field. The existing file commands still handle storage, fold...

Read and create spreadsheets

Use Read spreadsheet and Create spreadsheet under File Manager in a server workflow. They work with XLSX files and simple typed cell values. For CSV text files, use [Advanced file commands](/docs/commands/advanced-files). Read spreadsheet. Choose File, containing its actual contents. Use an uploaded...

Security

Twidget provides several built-in functions to enhance the security of your applications. Below is an overview of each security command, including its description, inputs, and outputs. For checksums, shared-secret signatures, webhook verification and safe text comparison, see [Cryptography commands]...

Process images

Read image details, make smaller copies, crop, rotate or change the format. Add these commands from File Manager in an endpoint, server function or event. They also work when a published function is called in the background and in supported endpoint test suites. Choose your image. Use a file contain...