Windows console application (.NET 4.5) for handling periodic FTP uploads and optionally sending a completion email.
- Windows console application for processing file upload jobs
- Upload jobs configured via plain-text JSON file
- Ability to compress files before uploading (ZIP compression)
- Replacement of
{date}
in destination file name with date inyyyy-MM-dd
format - Optional ability to send an email notification when a job is complete
- Does not handle scheduling
- .NET 4.5 or later on the system where the console application will run
- Software to schedule running tasks periodically such as Task Scheduler (optional)
- Mail server accepting SMTP connections (optional)
- Build the application or download a release
- Configure the mail portion in the
Uploader.Console.exe.config
(optional) - Configure the desired job(s) in the
jobs.json
file (see below) - Copy the application to the place where you want it to run
- Set up scheduling to automatically run the program (if desired)
Configure jobs by adding objects to jobs.json
describing the upload jobs. The format of the jobs.json
file is as follows:
{
"Jobs": [
{
"Name": "JobName",
"Path": "c:\\awesomefile.txt",
"Site": "ftp://localhost/awesomefile.zip",
"Username": "ftp",
"Password": "ftp",
"ZipBeforeUpload": "true",
"DeleteSourceAfterUpload": "false",
"EmailTo": "person@whatever",
"EmailBcc": "manager@whatever"
"EmailSubject": "The file was uploaded!",
"EmailBody": "Upload successful!"
},
{
...
}
]
}
The following fields can be present in a Job description object:
Name
- the name of the job (case-sensitive) - you run the job by callingUploader.Console.exe <name>
(with the above configuration, you'd runUploader.Console.exe JobName
)Path
- the full path to the file to upload, e.g.c:\\awesomefile.txt
(backslashes must be escaped: type them twice). An asterisk (*
) can be used to match partial file names - the upload will only be successful if there is a single file match.Site
- URL to upload the file to, e.g.ftp://localhost/awesomefile.zip
- if the configuration line contains{date}
it will be replaced with the current date inyyyy-MM-dd
formatUsername
- optional - login to the FTP sitePassword
- optional - password to the ftp siteZipBeforeUpload
- optional - whether or not to zip the file before uploading itDeleteSourceAfterUpload
- optional - if true, delete the source file once it has s been uploadedEmailTo
- optional - who to send an email to once the file is uploadedEmailBcc
- optional - a person to blind CC on the email that the software sendsEmailSubject
- optional - the subject of the email to sendEmailBody
- optional - the body of the email to send, ifEmailTo
andEmailSubject
are supplied butEmailBody
is not then just put the number of bytes uploaded in the body of the email.
Jobs can optionally be set to send email once they are complete. Email configuration is in the Uploader.Console.exe.config
file:
<system.net>
<mailSettings>
<smtp from="from-email-address@whatever">
<network host="smtp.server.hostname" port="25" />
</smtp>
</mailSettings>
</system.net>
Console logging is on by default. Additional logging configurations can be set in Uploader.Console.exe.config
:
In <appSettings>
add:
<add key="serilog:using:MSSqlSever" value="Serilog.Sinks.MSSqlServer"/>
<add key="serilog:write-to:MSSqlServer.restrictedToMinimumLevel" value="Information"/>
<add key="serilog:write-to:MSSqlServer.connectionString" value="[SQL Server connection string]"/>
<add key="serilog:write-to:MSSqlServer.tableName" value="[SQL Server logging table name]"/>
<add key="serilog:write-to:MSSqlServer.autoCreateSqlTable" value="true"/>
In <appSettings>
add:
<add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
<add key="serilog:write-to:Seq.serverUrl" value="[Seq logging endpoint]" />
<add key="serilog:write-to:Seq.apiKey" value="[optional API key here]" />
- Newtonsoft.Json
- Serilog
- Serilog.Settings.AppSettings
- Serilog.Sinks.Console
- Serilog.Sinks.Literate
- Serilog.Sinks.PeriodicBatching
- Serilog.Sinks.Seq
Code released under the MIT License.