File Trigger

The File Trigger allows you to execute a workflow when a file is created, modified, or deleted from a directory in your Application Files.

Application Files Trigger

Node Properties

The trigger requires the following configuration options …

File Path

First, specify a File Path within your Application Files that the trigger should watch for changes.

  • The path must start with a slash (/), which represents the root of your file directory.
  • To watch all files under a specific directory, as well as any subdirectories of that directory, enter the path to the directory to watch and end the path with a trailing slash (/). For example, to fire the trigger on all files under the “/experience” directory, enter a path of /experience/.
  • To watch changes to all Application Files, enter just a slash (/) for the File Path.
  • To watch a specific file, specify the path to the file and the file name, along with its extension. For example, to watch the file “my-logs.txt” under the directory “/experience/develop”, enter a path of /experience/develop/my-logs.txt.

Actions

Next, choose at least one action for which to invoke the trigger …

  • Trigger when a file is created: When a new file is created at or beneath the file path.
  • Trigger when a file content has changed: When an updated file is uploaded to the location of an existing file at or beneath the file path.
  • Trigger when a file has been removed: When a file is removed at or beneath the file path.

Note: Renaming or moving a file will cause the trigger to fire twice: first for the removal at the old path and then for the creation at the new path. Each action is evaluated against the trigger’s file path separately and only executes the workflow if the old path (in the removal case) and the new path (in the creation case) is at or beneath the specified path.

Payload

The trigger’s initial payload contains a data object with information about the file and the action that caused the workflow execution:

{
  "applicationId": "555555555555eeeeeeeeeeee",
  "applicationName": "My Great Application",
  "data": {
    "action": "create|update|delete",
    "file": {
      "name": "example.png",
      "type": "file",
      "parentDirectory": "/file/path/here/",
      "contentType": "image/png",
      "fileSize": 298232,
      "fileDimensions": {
        "width": 100,
        "height": 100
      },
      "authorType": "user",
      "authorId": "222222222222bbbbbbbbbbbb",
      "applicationId": "555555555555eeeeeeeeeeee",
      "lastUpdated": "2024-06-21T18:49:57.571Z",
      "creationDate": "2024-06-21T18:49:51.657Z",
      "status": "completed",
      "s3etag": "c47a166458d5adacf7b287efffa2026e",
      "id": "6696c9e239c10faed88d221a",
      "url": "https://files.on.example.com/555555555555eeeeeeeeeeee/example.png"
    }
  },
  "flowId": "333333333333cccccccccccc",
  "flowName": "My Great Workflow",
  "flowVersion": "myFlowVersion",
  "globals": {
    "aJsonGlobal": {
      "key": "value"
    },
    "aNumberGlobal": 42,
    "aStringGlobal": "My value"
  },
  "relayId": "222222222222bbbbbbbbbbbb",
  "relayType": "apiToken|flow|notebook|user",
  "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
  "triggerId": "/file/path/here/example.png",
  "triggerType": "appFile"
}

Was this page helpful?


Still looking for help? You can also search the WEGnology Forums or submit your question there.