Folder Worker
This worker automates the file import process. It allows parameterization such as filters, monitoring time, specific folders, and more, in addition to integrating with external services via API.
We use the client credentials OAuth2.0 flow for authentication with external client applications.
To find out how you can obtain your own Client ID / Client Secret pair, check the Create Secrets section.
Finding your Workspace Id and Tenant Id
Head to the Tasks Inbox screen and click the Import button, then the Folders tab.
Installation and Setup
Before using the worker, ensure that the executable is available on your system.
Download the appropriate executable for your operating system.
To check available options, open a terminal and run:
<executable> --help
Basic Usage
The basic command structure is:
<executable> [options]
Minimal example:
<executable> --client-id "your-client-id" --client-secret "your-client-secret" --tenant-id 201 --workspace-id 778
Available Options
Below are all available options:
--client-id
The unique identifier for authentication with external services.
Required
--client-secret
The secret key associated with the client ID for secure authentication.
Required
--tenant-id
The unique identifier of the tenant.
Required
--workspace-id
The unique identifier of the workspace.
Required
--api-url
The URL endpoint for integration with the processing worker, facilitating external service communication. Default value: https://cloud.smartdocumentor.net. Contact support for changes.
Optional
--tus-url
The URL endpoint for integration with the processing worker, facilitating external service communication. Default value: https://cloud.smartdocumentor.net. Contact support for changes.
Optional
--filters
Filters applied when monitoring files (e.g., `*.pdf`).
Optional
--action
Action to perform on files: Move
or Remove
. Default is Remove
.
Optional
--folder
The directory path where files should be monitored for changes or additions. Defaults to the current directory where the command is executed or the value provided (e.g., /path/to/watch).
Optional
--destination-folder
Directory where files will be moved if --action
is Move
. Required if Move
.
Required if --action
is Move
--include-subdirectories
Whether to include subdirectories. Default is false
.
Optional
--delay
Delay in milliseconds between file checks (minimum: 30,000 ms, maximum: 300,000 ms). Default is 30,000 ms
.
Optional
--help
Displays this help message.
Practical Examples
Run with basic credentials
<executable> --client-id "your-client-id" --client-secret "your-client-secret" --tenant-id 201 --workspace-id 778
Monitor PDF and JPG files
<executable> --client-id "your-client-id" --client-secret "your-client-secret" --tenant-id 201 --workspace-id 778 --filters "*.pdf|*.jpg"
Monitor a specific folder for PDF and JPG files every 30 seconds and move them to another folder
<executable> --client-id "your-client-id" --client-secret "your-client-secret" --tenant-id 201 --workspace-id 778 --folder "/path/to/watch" --destination-folder "/path/to/destination" --filters "*.pdf|*.jpg" --delay 30000 --action Move
Common Errors and Solutions
Error: "Filters must be provided" Cause: The
--filters
option is missing. Solution: Ensure that a valid filter is provided via command-line argument or configuration.Error: "Invalid delay value" Cause: The
--delay
value is outside the allowed range. Solution: The delay must be between 30,000 ms (30 seconds) and 300,000 ms (5 minutes).Error: "Invalid action type" Cause: The
--action
value is notMove
orRemove
. Solution: Ensure that the action is correctly set asMove
orRemove
.Error: "Destination folder required when action is Move" Cause: The
--destination-folder
is missing when--action Move
is used. Solution: Provide a valid destination folder via command-line argument or configuration.Error: "API Base URL must be provided" Cause: The
--api-url
is missing. Solution: Ensure the API base URL is included in the command-line arguments.Error: "TUS Base URL must be provided" Cause: The
--tus-url
is missing. Solution: Provide a valid TUS upload service URL.Error: "Client ID is required" Cause: The
--client-id
is missing. Solution: Ensure the client ID is correctly specified in the command.Error: "Client Secret is required" Cause: The
--client-secret
is missing. Solution: Provide a valid client secret.Error: "Tenant ID must be greater than zero" Cause: The
--tenant-id
is missing or set to zero. Solution: Ensure the tenant ID is a positive integer.Error: "Workspace ID must be greater than zero" Cause: The
--workspace-id
is missing or set to zero. Solution: Provide a valid workspace ID greater than zero.
Last updated