File Detect
AI-generatedOverview
The File Detect node analyzes a specified file based on multiple configurable conditions such as existence, file extension, file type, text content, and file permissions. It routes the input data into two outputs: 'true' if the combined conditions are met according to the selected logic operation (AND/OR), and 'false' otherwise. This node is useful for workflows that need to validate or filter files before processing, such as ensuring a file exists and matches expected criteria before further automation steps.
Use Case Examples
- Check if a file exists and has a .txt extension before processing its content.
- Verify that a file is of an expected type (e.g., image or video) and contains specific text before uploading.
- Ensure a file has read and write permissions before performing file operations.
Properties
| Name | Meaning |
|---|---|
| File Path | Path to the file to detect, required for all checks. |
| Check File Exists | Enable to check if the specified file exists. |
| Check File Extension | Enable to check if the file extension matches allowed extensions. |
| Allowed Extensions | Comma-separated list of allowed file extensions to check against, used only if 'Check File Extension' is enabled. |
| Check File Type | Enable to check the file type based on file header/magic bytes. |
| Expected File Types | Select expected file types to check against, used only if 'Check File Type' is enabled. |
| Check Text Content | Enable to check if a text file contains specified content. |
| Search Text | Text or pattern to search for in the file, used only if 'Check Text Content' is enabled. |
| Use Regex | Use regular expression for text matching, used only if 'Check Text Content' is enabled. |
| Check File Permissions | Enable to check if the file has specific permissions. |
| Required Permissions | Select permissions (read, write, execute) to check for, used only if 'Check File Permissions' is enabled. |
| Logic Operation | How to combine multiple conditions: AND requires all conditions to be true, OR requires any condition to be true. |
Output
JSON
fileDetectResultfilePath- The path of the file checked.finalResult- Boolean indicating if the combined conditions passed based on the logic operation.conditionResults- Array of boolean results for each individual condition checked.logicOperation- The logic operation used to combine conditions ('and' or 'or').
Dependencies
- Utility functions for file checks such as existence, extension, type, content, and permissions from an external utils module.
Troubleshooting
- Ensure the file path is correctly specified; missing file path will cause an error.
- If 'Check File Extension' is enabled, provide valid extensions in the allowed extensions list.
- When using 'Check File Type', ensure the file is accessible and readable to determine its type.
- For 'Check Text Content' with regex enabled, ensure the regex pattern is valid to avoid matching errors.
- File permission checks require appropriate system permissions to read file metadata; lack of permissions may cause failures.
- If multiple conditions are enabled, verify the logic operation (AND/OR) matches the intended condition combination logic.