-
Notifications
You must be signed in to change notification settings - Fork 0
WebDavService
The WebDavService offers the possibility to upload or download files to a WebDavServer.
The service is integrated via dependency injection:
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, configuration) =>
{
configuration.Sources.Clear();
configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
IConfigurationRoot configurationRoot = configuration.Build();
Configuration = configurationRoot;
}).ConfigureServices((services) =>
{
services.AddSingleton<IConfigurationRoot>(Configuration);
services.AddHostedService<ConsoleService>(); // This is the main service, who holds all methods we are using.
services.AddSingleton<IWebDavService, WebDavService>();
});As a minimum configuration we need the following settings: The respective values are for demo purposes only and must be adjusted.
{
"wd_password": "Password",
"wd_subfolder": "Subfolder Path",
"wd_url": "Webdav Server Url",
"wd_username": "Username"
}The "wd_password" is the password for the WebDav server, "wd_subfolder" specifies the path to which the file must be uploaded. The "wd_url" is the URL of the WebDav server. The "wd_username" is the login username.
The following methods can be called:
The method downloads a file (remotefilepath) and saves it in the localfilepath.
IMPORTANT: Both paths contain both the path to the file and the file name itself.
The method deletes a file.
IMPORTANT: The remotefilepath contains the path to the file and also the file name itself.
The method uploads a file to a WebDav path. IMPORTANT: Both paths include the path to the file as well as the file name itself.