All Projects → skazantsev → WebDavClient

skazantsev / WebDavClient

Licence: MIT License
Asynchronous cross-platform WebDAV client for .NET Core

Programming Languages

C#
18002 projects
powershell
5483 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to WebDavClient

webdav client
A dart WebDAV client library
Stars: ✭ 30 (-69.39%)
Mutual labels:  webdav, webdav-client
gitsynchista
Python tool for Pythonista to synchronize local files with a Github repository hosted on a WebDav server
Stars: ✭ 27 (-72.45%)
Mutual labels:  webdav, webdav-client
Filestash
🦄 A modern web client for SFTP, S3, FTP, WebDAV, Git, Minio, LDAP, CalDAV, CardDAV, Mysql, Backblaze, ...
Stars: ✭ 5,231 (+5237.76%)
Mutual labels:  webdav, webdav-client
webdav-js
A simple WebDAV client written in JS for use as a bookmarklet, or integration into a web server.
Stars: ✭ 51 (-47.96%)
Mutual labels:  webdav, webdav-client
CSLisp
C# Scheme / Lisp implementation for embedding in .NET projects
Stars: ✭ 27 (-72.45%)
Mutual labels:  dotnet-standard
webdav-server-rs
webdav server in rust
Stars: ✭ 65 (-33.67%)
Mutual labels:  webdav
colorify
Colorify - C# .Net Console Library with Text Format: colors, alignment and lot more [ Win+Mac+Linux ]
Stars: ✭ 49 (-50%)
Mutual labels:  dotnet-standard
pipedrive-dotnet
Pipedrive.net is an async .NET Standard client for pipedrive.com
Stars: ✭ 31 (-68.37%)
Mutual labels:  dotnet-standard
dapr-sidekick-dotnet
Dapr Sidekick for .NET - a lightweight lifetime management component for Dapr
Stars: ✭ 113 (+15.31%)
Mutual labels:  dotnet-standard
crypthash-net
CryptHash.NET is a .NET multi-target library to encrypt/decrypt/hash/encode/decode strings and files, with an optional .NET Core multiplatform console utility.
Stars: ✭ 33 (-66.33%)
Mutual labels:  dotnet-standard
Waveshare.EPaperDisplay
.Net Core Library to show images on Waveshare E-Paper Displays
Stars: ✭ 17 (-82.65%)
Mutual labels:  dotnet-standard
onepile
Playground for the future of private notes and document management
Stars: ✭ 41 (-58.16%)
Mutual labels:  webdav
minio-rclone-webdav-server
A @rclone served WebDAV server with @minio as the s3 storage backend docker example
Stars: ✭ 17 (-82.65%)
Mutual labels:  webdav
MayMeow.Cryptography
🔐 Cryptography library for .NET
Stars: ✭ 12 (-87.76%)
Mutual labels:  dotnet-standard
King.Service
Task scheduling for .NET
Stars: ✭ 34 (-65.31%)
Mutual labels:  dotnet-standard
TypeKitchen
TypeKitchen is a set of small libraries for fast metaprogramming in .NET Standard.
Stars: ✭ 14 (-85.71%)
Mutual labels:  dotnet-standard
PandaNote
iOS markdown Note App / iOS的markdown笔记应用
Stars: ✭ 32 (-67.35%)
Mutual labels:  webdav
SocksSharp
SocksSharp provides support for Socks4/4a/5 proxy servers to HttpClient
Stars: ✭ 75 (-23.47%)
Mutual labels:  dotnet-standard
Warframe.NET
Under rewrite: Collection of Warframe libraries for C# developers.
Stars: ✭ 18 (-81.63%)
Mutual labels:  dotnet-standard
pnpcore
The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
Stars: ✭ 169 (+72.45%)
Mutual labels:  dotnet-standard

WebDAV .NET client Build status

Asynchronous cross-platform WebDAV client for .NET Core and other runtimes. It aims to have a full support of RFC4918.

Installation

Install WebDav.Client via NuGet.

Install-Package WebDav.Client

Supported platforms

  • .NET Core 1.0+
  • .NET Framework 4.5+
  • Mono
  • Xamarin
  • UWP

For more information see .NET Standard.

Usage notes

WebDavClient uses HttpClient under the hood that is why it is a good practice to share a single instance for the lifetime of the application.

If you use a dependency injection container to manage dependencies it is a good practice to register WebDavClient as a singleton.

It's also possible to instantiate WebDavClient with a pre-configured instance of HttpClient.

When using GetRawFile / GetProcessedFile don't forget to dispose the response.

Usage examples

Basic usage

class Example
{
    public static IWebDavClient _client = new WebDavClient();

    public void MakeCalls()
    {
        var result = await _client.Propfind("http://mywebdav/1.txt");
        if (result.IsSuccessful)
            // continue ...
        else
            // handle an error
    }
}

Using BaseAddress

var clientParams = new WebDavClientParams { BaseAddress = new Uri("http://mywebdav/") };
using (var client = new WebDavClient(clientParams))
{
    await client.Propfind("1.txt");
}

Operations with files and directories (resources & collections)

var clientParams = new WebDavClientParams { BaseAddress = new Uri("http://mywebdav/") };
using (var client = new WebDavClient(clientParams))
{
    await client.Mkcol("mydir"); // create a directory

    await client.Copy("source.txt", "dest.txt"); // copy a file

    await client.Move("source.txt", "dest.txt"); // move a file

    await client.Delete("file.txt", "dest.txt"); // delete a file

    using (var response = await client.GetRawFile("file.txt")) // get a file without processing from the server
    {
        // use response.Stream
    }

    using (var response = await client.GetProcessedFile("file.txt")) // get a file that can be processed by the server
    {
        // use response.Stream
    }

    await client.PutFile("file.xml", File.OpenRead("file.xml")); // upload a resource
}

Authentication using an access token

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = 
    new AuthenticationHeaderValue("Bearer", accessToken);
var client = new WebDavClient(httpClient);

Authentication using NetworkCredential

var clientParams = new WebDavClientParams
{
    BaseAddress = new Uri("http://mywebdav/"),
    Credentials = new NetworkCredential("user", "12345")
};
var client = new WebDavClient(clientParams);

PROPFIND example

// list files & subdirectories in 'mydir'
var result = await _client.Propfind("http://mywebdav/mydir");
if (result.IsSuccessful)
{
    foreach (var res in result.Resources)
    {
        Trace.WriteLine("Name: " + res.DisplayName);
        Trace.WriteLine("Is directory: " + res.IsCollection);
        // etc.
    }
}

PROPFIND with custom properties

var propfindParams = new PropfindParameters
{
    Namespaces = new [] { new NamespaceAttr("myns", "https://example.com/") },
    CustomProperties = new [] { XName.Get("myprop", "https://example.com/") }
};
var result = await client.Propfind("http://mywebdav/mydir", propfindParams);

Custom headers

var propfindParams = new PropfindParameters
{
    Headers = new List<KeyValuePair<string, string>>
    {
        new KeyValuePair<string, string>("User-Agent", "Not a browser")
    }
};
var result = await _client.Propfind("http://mywebdav/1.txt", propfindParams);

Content-Range or other content headers

// Content headers need to be set directly on HttpContent instance.
var content = new StreamContent(File.OpenRead("test.txt"));
content.Headers.ContentRange = new ContentRangeHeaderValue(0, 2);
var result = await _client.PutFile("http://mywebdav/1.txt", content);

Synchronous API

  // will block the current thread, so use it cautiously
  var result = _client.Propfind("1.txt").Result;

License

WebDavClient is licensed under the MIT License. See LICENSE.txt for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].