ApplicationExperience

File: Create Node

The File: Create Node allows a workflow to create a file within your Application Files.

File: Create Node

Node Properties

There are two main configuration sections for the File: Create Node …

File Configuration

File: Create Node Config

First is to configure the details of the file to create. All applicable fields are templatable:

  • File Name: (Required) The name of the file to create or update.
  • Parent Directory: (Optional) The full path in which to create the file. If any of the specified directories do not already exist, they will be created.
  • Content Type: (Optional) The MIME type of the file to create. If left blank, the MIME type will be guessed based on the file name.
  • File Encoding: (Optional) The encoding of the file contents, by default this is UTF8. The following are valid encodings: ASCII, UTF8, UTF16LE, Base64, Binary, Hex.
  • File Contents: (Optional) The contents of the file to create.

File: Create Node Overwrite

If your application already contains the file specified above, you can handle that in one of two ways:

  • Cancel and return an error if the file exists: (Default) This option will return an error on the payload and not write any content to the configured file.
  • Overwrite the file with my new content if it exists: This option will completely replace the file with the configured file content.

Result Path

File: Create Node Output

The success or failure of the operation can optionally be placed at the specified payload path. If the operation fails, the result object will contain an error object instead of its normal result.

Node Example

The following is the result of running the above workflow:

{
  ...
  "data": {
    "fileStatus": {
      "id": "5d5aa5bde697320006842c02",
      "url": "https://files.on.losant.com/5c365aee856/important/business.csv",
      "s3etag": "7553490ea58a9e576a6fd75c2e0dc43f",
      "status": "completed",
      "creationDate": "2019-08-19T13:35:57.763Z",
      "lastUpdated": "2019-08-19T13:35:58.075Z",
      "contentType": "text/csv",
      "fileSize": 32,
      "type": "file",
      "parentDirectory": "/important/",
      "name": "business.csv",
      "authorType": "flow",
      "authorId": "5d56e856005f990006c855bf",
      "applicationId": "5c365aee856"
    }
  }
  ...
}

Node Errors

The following is an example of a failed operation:

{
  ...
  "data": {
    "fileStatus": {
      "error": {
        "message": "File business.csv failed to create or update: File business.csv already exists",
        "type": "FILE_CREATE_ERROR"
      }
    }
  }
  ...
}