Do you need to listen and react for file creation events? Folder Dog is ready to help. Currently you can send email, webhook or do both.
If you will like this app, please give it a star ⭐️
It binds to OS file events and subscribes specifically to file creation events.
It uses an SMTP server. You need to open a relay from the IP where this app is running. You can provide the message subject, send from address, and recipient information such as SendTos
, SendCcs
, and SendBccs
.
This is a nice to have feature for your virtual machine or any other onprem server type where you need to bind and execute something on the file creation event (similar functionality is available out of the box for some cloud resources, such as Azure Storage Account).
Moreover, if you are seeking a tool that can listen to webhooks and execute scripts, feel free to check this out.
Here is configuration example:
"Webhook": {
"Url": "http://localhost:58427/webhook/v1",
"Method": "POST",
"Body": {
"Key": "<YourSecretKey>",
"Script": "Test-Script.ps1",
"Param": "-Param1 \"{{fileName}}\" -Param2 \"{{fileFullPath}}\""
}
}
URL
- WebHook server address
Method
- Can be POST
or GET
Body
- It is essential a dictionary. You can provide your values here. The one thing to remember - {{fileName}}
and {{fileFullPath}}
masks will be replaced with the values from the file event. Also, despite you can provide a number or the datetime as a value everything will be converted to a string.
Another configuration example:
"Webhook": {
"Url": "http://localhost:58427/webhook/v1",
"Method": "POST",
"Body": {
"MyAwesomeParam": "OmgItIsAWebhook",
"NotThatAwesome": "ButStill",
"ThisWillBeConvertedToAString": 1
}
}
And one more with get:
"Webhook": {
"Url": "http://azure-function.azure.com/myAwesomeFunc",
"Method": "GET"
}
Currently, you cannot pass the values from the file event using GET
method. It can be easily integrated. If you need it, then welcome to a discussion section on this github page.
Once you run the app, it will log messages to both the console and to the file log. By default, it creates a log
directory in the current folder and every day creates a log file. The log files are rotated for 31 days by default.
You can control how to handle edge cases such as:
- A file is still open by another process (Some apps might write content by batches).
- We had already processed the file before, but now received the same event. You can control what to do in this case. By default if we have received an event about the file that was processed before and the size for this file is the same, then the app will skip further processing and log the message.
Also, you can provide one or many file extensions to listen to. For example, only excel or csv files.
Each file creation event executes in a dedicated thread from the ThreadPool
. If all thread pools are busy, then the event will be queued and processed later.
Configuration file appsettings.json
must be present in the same app with folder.
Example:
{
"Binding": {
"FolderPath": "./",
"ListenInSubfolders": false,
"FileExtensions": [
"csv",
"txt"
]
},
"FileService": {
"RepeatAccessAttempts": 3,
"WaitUntilNextRetryInMilliseconds": 1000,
"WaitBeforeExecutionInMilliseconds": 1000,
"SkipProcessedFiles": true
},
"Webhook": {
"Url": "http://localhost:58427/webhook/v1",
"Method": "POST",
"Body": {
"Key": "<YourSecretKey>",
"Script": "Test-Script.ps1",
"Param": "-Param1 \"{{fileName}}\" -Param2 \"{{fileFullPath}}\""
}
},
"Email": {
"SendFrom": "no-reply@mail.com",
"SendTos": [
"user@mail.com"
],
"SmtpServerHost": "<PutYourSmtpServerIpOrHostName>",
"SmtpServerPortNumber": 25,
"MessageSubject": "File has been created"
},
"Serilog": {
"MinimumLevel": "Information",
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "./logs/log-.txt",
"rollingInterval": "Day",
"retainedFileCountLimit": 31
}
},
{
"Name": "Console"
}
]
}
}
- Bindings - Provide folder path where to listen as well as file extensions.
- FileService - Configuration for the file service to control how to handle edge cases.
- Email - Mail configuration. Beside params in the config example you can add array of
SendCcs
andSendBccs
- Serilog - Logging configuration. By default it will create a
logs
folder in the working directory. Every day a log file will be created. Rotation is enabled and set to 31 days. - Webhook - Define hook configuration. URL and Method are required properties here.
Method
can be eitherPOST
orGET
. SpecifyBody
dictionary in case you setMethod
toPOST
.
- .NET 7 runtime if you don't use the self-contained version
- The SMTP server must relay emails from the IP where the app runs
You can download the latest release.
If you have a .NET7 runtime installed, then you can chose framework-dependent
.
It has the smaller footprint.
You can also download a precompiled version for your Operation system.
After you extract the artifact from the console run it:
Please leave feedback to make this small app better ❤️.